lib/Mail/DMARC/Report/Send/HTTP.pm

filter: Statementstmt 53.1% 17 / 32 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 46.8% 22 / 47 CC 5 SCAR 27.4
CC
5
Cov
42%
post
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 15.5
« lib/Mail/DMARC/HTTP.pm ↑ Summary lib/Mail/DMARC/PurePerl.pm »
1 package Mail::DMARC::Report::Send::HTTP;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '2.20261110';
7  
8 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 #use Data::Dumper;
11 #use HTTP::Tiny; # a possibility
12 #use Net::HTTP; # lazy loaded in 'post'
13  
14 2 ▶use parent 'Mail::DMARC::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 0 ▶sub post( $self, $uri, $report, $gz ) {
Subroutine post: not called CC=5 SCAR=34.0
Pod undocumented
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 ▶ eval "require Net::HTTP" or return;
Branch: 1 branch
BranchTrueFalseTotal
eval "require Net::HTTP" or return 0 0 0
24  
25 0 my $ver = $Mail::DMARC::Base::VERSION;
26 0 ▶ my $s = Net::HTTP->new( Host => $uri->host ) or croak $@;
Branch: 1 branch
BranchTrueFalseTotal
my $s = "Net::HTTP"->new("Host", $uri->host) or croak($@) 0 0 0
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 ▶ croak "read failed: $!" unless defined $n;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $n 0 0 0
37 0 ▶ last unless $n;
Branch: 1 branch
BranchTrueFalseTotal
unless $n 0 0 0
38 0 print $buf;
39 0 return 1;
40 }
41 0 return 0;
42 }
43  
44 2 1;
45  
46 __END__
« lib/Mail/DMARC/HTTP.pm ↑ Summary lib/Mail/DMARC/PurePerl.pm »