« blib/lib/Mail/DMARC/Result/Reason.pm
↑ Summary
lib/Mail/DMARC/Report/Store/SQL/Grammars/MySQL.pm »
| 1 | package Mail::DMARC::Report::Send::HTTP; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use feature 'signatures'; | ||
| 5 | |||
| 6 | our $VERSION = '2.20260827'; | ||
| 7 | |||
| 8 | use Carp; | ||
| 9 | |||
| 10 | #use Data::Dumper; | ||
| 11 | #use HTTP::Tiny; # a possibility | ||
| 12 | #use Net::HTTP; # lazy loaded in 'post' | ||
| 13 | |||
| 14 | use parent 'Mail::DMARC::Base'; | ||
| 15 | |||
| 16 | sub post( $self, $uri, $report, $gz ) { | ||
| 17 | |||
| 18 | carp "http send feature not complete!"; | ||
| 19 | return; | ||
| 20 | |||
| 21 | ## no critic (Unreachable,Eval) | ||
| 22 | # TODO: test against real HTTP server, validate HTTP response | ||
| 23 | eval "require Net::HTTP" or return; | ||
| 24 | |||
| 25 | my $ver = $Mail::DMARC::Base::VERSION; | ||
| 26 | my $s = Net::HTTP->new( Host => $uri->host ) or croak $@; | ||
| 27 | $s->write_request( | ||
| 28 | POST => $uri->path, | ||
| 29 | 'User-Agent' => "Mail::DMARC/$ver" | ||
| 30 | ); | ||
| 31 | my ( $code, $mess, %h ) = $s->read_response_headers; | ||
| 32 | |||
| 33 | while (1) { | ||
| 34 | my $buf; | ||
| 35 | my $n = $s->read_entity_body( $buf, 1024 ); | ||
| 36 | croak "read failed: $!" unless defined $n; | ||
| 37 | last unless $n; | ||
| 38 | print $buf; | ||
| 39 | return 1; | ||
| 40 | } | ||
| 41 | return 0; | ||
| 42 | } | ||
| 43 | |||
| 44 | 1; | ||
| 45 | |||
| 46 | __END__ | ||
| 47 | |||
| 48 | =pod | ||
| 49 | |||
| 50 | =head1 NAME | ||
| 51 | |||
| 52 | Mail::DMARC::Report::Send::HTTP - utility methods to send reports by HTTP | ||
| 53 | |||
| 54 | =head1 VERSION | ||
| 55 | |||
| 56 | version 2.20260827 | ||
| 57 | |||
| 58 | =head1 12.2.2. HTTP | ||
| 59 | |||
| 60 | Where an "http" or "https" method is requested in a Domain Owner's | ||
| 61 | URI list, the Mail Receiver MAY encode the data using the | ||
| 62 | "application/gzip" media type ([GZIP]) or MAY send the Appendix C | ||
| 63 | data uncompressed or unencoded. | ||
| 64 | |||
| 65 | The header portion of the POST or PUT request SHOULD contain a | ||
| 66 | Subject field as described in Section 12.2.1. | ||
| 67 | |||
| 68 | HTTP permits the use of Content-Transfer-Encoding to upload gzip | ||
| 69 | content using the POST or PUT instruction after translating the | ||
| 70 | content to 7-bit ASCII. | ||
| 71 | |||
| 72 | =head1 AUTHORS | ||
| 73 | |||
| 74 | =over 4 | ||
| 75 | |||
| 76 | =item * | ||
| 77 | |||
| 78 | Matt Simerson <msimerson@cpan.org> | ||
| 79 | |||
| 80 | =item * | ||
| 81 | |||
| 82 | Davide Migliavacca <shari@cpan.org> | ||
| 83 | |||
| 84 | =item * | ||
| 85 | |||
| 86 | Marc Bradshaw <marc@marcbradshaw.net> | ||
| 87 | |||
| 88 | =back | ||
| 89 | |||
| 90 | =head1 COPYRIGHT AND LICENSE | ||
| 91 | |||
| 92 | This software is copyright (c) 2026 by Matt Simerson. | ||
| 93 | |||
| 94 | This is free software; you can redistribute it and/or modify it under | ||
| 95 | the same terms as the Perl 5 programming language system itself. | ||
| 96 | |||
| 97 | =cut |