line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::DMARC::Report::Send::HTTP; |
2
|
10
|
|
|
10
|
|
136
|
use strict; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
333
|
|
3
|
10
|
|
|
10
|
|
58
|
use warnings; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
507
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.20210927'; |
6
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
98
|
use Carp; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
713
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#use Data::Dumper; |
10
|
|
|
|
|
|
|
#use HTTP::Tiny; # a possibility |
11
|
|
|
|
|
|
|
#use Net::HTTP; # lazy loaded in 'post' |
12
|
|
|
|
|
|
|
|
13
|
10
|
|
|
10
|
|
70
|
use parent 'Mail::DMARC::Base'; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
65
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub post { |
16
|
0
|
|
|
0
|
0
|
|
my ( $self, $uri, $report, $gz ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
carp "http send feature not complete!"; |
19
|
0
|
|
|
|
|
|
return; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
## no critic (Unreachable,Eval) |
22
|
|
|
|
|
|
|
# TODO: test against real HTTP server, validate HTTP response |
23
|
0
|
0
|
|
|
|
|
eval "require Net::HTTP" or return; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $ver = $Mail::DMARC::Base::VERSION; |
26
|
0
|
0
|
|
|
|
|
my $s = Net::HTTP->new( Host => $uri->host ) or croak $@; |
27
|
0
|
|
|
|
|
|
$s->write_request( |
28
|
|
|
|
|
|
|
POST => $uri->path, |
29
|
|
|
|
|
|
|
'User-Agent' => "Mail::DMARC/$ver" |
30
|
|
|
|
|
|
|
); |
31
|
0
|
|
|
|
|
|
my ( $code, $mess, %h ) = $s->read_response_headers; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
while (1) { |
34
|
0
|
|
|
|
|
|
my $buf; |
35
|
0
|
|
|
|
|
|
my $n = $s->read_entity_body( $buf, 1024 ); |
36
|
0
|
0
|
|
|
|
|
croak "read failed: $!" unless defined $n; |
37
|
0
|
0
|
|
|
|
|
last unless $n; |
38
|
0
|
|
|
|
|
|
print $buf; |
39
|
0
|
|
|
|
|
|
return 1; |
40
|
|
|
|
|
|
|
} |
41
|
0
|
|
|
|
|
|
return 0; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |