| 1 | package HTTP::Any::AnyEvent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | sub do_http { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | ▶ | my ($http_request, $url, $opt, $cb) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_http: not called CC=22 SCAR=62.3
Pod
undocumented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | ▶ | my $method = $$opt{method} || "GET"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opt->{'method'} || 'GET'
MC/DC0%0/1
$opt->{'method'} || 'GET'
$opt->{'method'}
Truth table0%0/2
A
A= $opt->{'method'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | my %headers = (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | %headers = %{$$opt{headers}} if $$opt{headers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | $headers{"user-agent"} = $$opt{agent} if $$opt{agent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | $headers{"referer"} = $$opt{referer} if $$opt{referer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | if ($$opt{compressed} or $$opt{gzip}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt->{"compressed"} or $opt->{"gzip"}
MC/DC0%0/2
$opt->{"compressed"} or $opt->{"gzip"}
$opt->{"compressed"}
$opt->{"gzip"}
Truth table0%0/3
A or B
A= $opt->{"compressed"}B= $opt->{"gzip"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | $headers{'Accept-Encoding'} = 'gzip, deflate'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | require Compress::Raw::Zlib; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my %args = (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | $args{headers} = \%headers if keys %headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | $args{timeout} = $$opt{timeout} if $$opt{timeout}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if (defined $$opt{max_redirect}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $args{recurse} = $$opt{max_redirect}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $args{recurse} = 7; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if (my $proxy = $$opt{proxy}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if ($proxy =~ m/^socks/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $proxy =~ s!^socks://!socks5://!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $args{socks} = $proxy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } elsif ($proxy =~ m!^(\w+://)?(.+):(\d+)$!) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if ($1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $args{proxy} = [$2, $3, $1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $args{proxy} = [$2, $3]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ($$opt{cookie}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $args{cookie_jar} = $$opt{cookie}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } elsif (defined $$opt{cookie}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $args{cookie_jar} = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | $args{persistent} = $$opt{persistent} if exists $$opt{persistent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my $max_size = $$opt{max_size}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $on_header = $$opt{on_header}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $on_body = $$opt{on_body}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $body_from_on_body_length = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my @body_from_on_body = (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ($max_size or $on_header or $on_body) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$max_size or $on_header or $on_body
$max_size or $on_header
MC/DC0%0/3
$max_size or $on_header or $on_body
$max_size
$on_header
$on_body
Truth table0%0/4
A or B or C
A= $max_sizeB= $on_headerC= $on_body
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $headers_got = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $content_encoding; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | my $inflate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | $args{on_header} = sub { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | my ($headers) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $body_from_on_body_length = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | @body_from_on_body = (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $headers_got = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my ($is_success, $status, $h, $redirects) = headers($headers); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $content_encoding = $$h{'content-encoding'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if (($$opt{compressed} or $$opt{gzip}) and $content_encoding) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$opt->{"compressed"} || $opt->{"gzip"} and $content_encoding
$opt->{"compressed"} or $opt->{"gzip"}
MC/DC0%0/3
$opt->{"compressed"} || $opt->{"gzip"} and $content_encoding
$opt->{"compressed"}
$opt->{"gzip"}
$content_encoding
Truth table0%0/5
A or B and C
A= $opt->{"compressed"}B= $opt->{"gzip"}C= $content_encoding
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ($content_encoding eq 'deflate') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $inflate = Compress::Raw::Zlib::Inflate->new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } elsif ($content_encoding eq 'gzip') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $inflate = Compress::Raw::Zlib::Inflate->new(-WindowBits => Compress::Raw::Zlib::WANT_GZIP()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ($on_header) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | $on_header->($is_success, $h, $redirects) or return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | $args{on_body} = sub { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | my ($partial_body, $headers) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=13 SCAR=52.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $body_from_on_body_length += length $partial_body; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | push @body_from_on_body, $partial_body unless $on_body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if ($headers_got and $max_size and $body_from_on_body_length > $max_size) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$headers_got and $max_size and $body_from_on_body_length > $max_size
$headers_got and $max_size
MC/DC0%0/3
$headers_got and $max_size and $body_from_on_body_length > $max_size
$headers_got
$max_size
$body_from_on_body_length > $max_size
Truth table0%0/4
A and B and C
A= $headers_gotB= $max_sizeC= $body_from_on_body_length > $max_size
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if ($headers_got and $on_body) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$headers_got and $on_body
MC/DC0%0/2
$headers_got and $on_body
$headers_got
$on_body
Truth table0%0/3
A and B
A= $headers_gotB= $on_body
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ($inflate) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $status = $inflate->inflate($partial_body, my $output); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $status == Compress::Raw::Zlib::Z_OK() or $status == Compress::Raw::Zlib::Z_STREAM_END() or warn "inflation failed: $status\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$status == Compress::Raw::Zlib::Z_OK() or $status == Compress::Raw::Zlib::Z_STREAM_END()
MC/DC0%0/2
$status == Compress::Raw::Zlib::Z_OK() or $status == Compress::Raw::Zlib::Z_STREAM_END()
$status == Compress::Raw::Zlib::Z_OK()
$status == Compress::Raw::Zlib::Z_STREAM_END()
Truth table0%0/3
A or B
A= $status == Compress::Raw::Zlib::Z_OK()B= $status == Compress::Raw::Zlib::Z_STREAM_END()
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if ($output) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | $on_body->($output) or return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | $on_body->($partial_body) or return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ($method eq "POST") { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | $args{headers}{"Content-Type"} ||= "application/x-www-form-urlencoded"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"headers"}{"Content-Type"} ||= "application/x-www-form-urlencoded"
MC/DC0%0/1
$args{"headers"}{"Content-Type"} ||= "application/x-www-form-urlencoded"
$args{"headers"}{"Content-Type"}
Truth table0%0/2
A
A= $args{"headers"}{"Content-Type"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $args{body} = $$opt{body}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | $http_request->( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | $method => $url, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | %args, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | sub { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | my ($body, $headers) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=15 SCAR=54.8
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my ($is_success, $status, $h, $redirects) = headers($headers); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if (not $body) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | if ($status >= 590) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $is_success = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $body = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | if ($status == 598) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $$h{"Reason"} = "MaxSize"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $$h{"Status"} = $status = 599; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | delete $$h{"Orig$_"} foreach qw(Status Reason); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } elsif (@body_from_on_body) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $body = join "", @body_from_on_body; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $$h{Protocol} = "HTTP/" . $$h{HTTPVersion}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $content_encoding = $$h{'content-encoding'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if ($body and ($$opt{compressed} or $$opt{gzip}) and $content_encoding) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$body and $opt->{"compressed"} || $opt->{"gzip"} and $content_encoding
$body and $opt->{"compressed"} || $opt->{"gzip"}
$opt->{"compressed"} or $opt->{"gzip"}
MC/DC0%0/4
$body and $opt->{"compressed"} || $opt->{"gzip"} and $content_encoding
$body
$opt->{"compressed"}
$opt->{"gzip"}
$content_encoding
Truth table0%0/6
A and B or C and D
A= $bodyB= $opt->{"compressed"}C= $opt->{"gzip"}D= $content_encoding
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if ($content_encoding eq 'deflate' or $content_encoding eq 'gzip') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$content_encoding eq "deflate" or $content_encoding eq "gzip"
MC/DC0%0/2
$content_encoding eq "deflate" or $content_encoding eq "gzip"
$content_encoding eq "deflate"
$content_encoding eq "gzip"
Truth table0%0/3
A or B
A= $content_encoding eq "deflate"B= $content_encoding eq "gzip"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | my $inflate = Compress::Raw::Zlib::Inflate->new($content_encoding eq 'gzip' ? (-WindowBits => Compress::Raw::Zlib::WANT_GZIP()) : ()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $status = $inflate->inflate($body, my $output); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | $status == Compress::Raw::Zlib::Z_OK() or $status == Compress::Raw::Zlib::Z_STREAM_END() or warn "inflation failed: $status\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$status == Compress::Raw::Zlib::Z_OK() or $status == Compress::Raw::Zlib::Z_STREAM_END()
MC/DC0%0/2
$status == Compress::Raw::Zlib::Z_OK() or $status == Compress::Raw::Zlib::Z_STREAM_END()
$status == Compress::Raw::Zlib::Z_OK()
$status == Compress::Raw::Zlib::Z_STREAM_END()
Truth table0%0/3
A or B
A= $status == Compress::Raw::Zlib::Z_OK()B= $status == Compress::Raw::Zlib::Z_STREAM_END()
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $cb->($is_success, $output, $h, $redirects); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $cb->($is_success, $body, $h, $redirects); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | sub headers { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | my ($headers) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headers: not called CC=3 SCAR=24.8
Pod
undocumented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my $status = $$headers{Status}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | my $is_success = ($status >= 200 and $status < 300) ? 1 : 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$status >= 200 and $status < 300
MC/DC0%0/2
$status >= 200 and $status < 300
$status >= 200
$status < 300
Truth table0%0/3
A and B
A= $status >= 200B= $status < 300
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my ($h, @hr) = _headers($headers); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return $is_success, $status, $h, \@hr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | sub _headers { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | my ($h) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_headers: not called CC=2 SCAR=17.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my %h = map { $_ => $$h{$_} } grep { $_ ne 'Redirect' } keys %$h; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if (my $r = $$h{'Redirect'}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | return \%h, _headers($$r[1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | return \%h; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||