Decode/Encode/HTTP/Response.pm

filter: Statementstmt 44.7% 17 / 38 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 71.4% 5 / 7 Podpod 100% 1 / 1 totaltotal 37.1% 23 / 62 CC 7 SCAR 34.2
CC
7
Cov
33%
decode
56.0
_build_parser
2.0
BEGIN
1.0
CRAP 30.7
↑ Summary Decode/Encode/HTTP/Response/Parser.pm »
1  
2 package Data::Decode::Encode::HTTP::Response;
3 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use namespace::clean -except => qw(meta);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Data::Decode::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Data::Decode::Util qw(try_decode pick_encoding);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Encode();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 has parser => (
10 is => 'ro',
11 isa => 'Data::Decode::Encode::HTTP::Response::Parser',
12 lazy_build => 1,
13 );
14  
15 0 ▶sub _build_parser {
Subroutine _build_parser: not called CC=1 SCAR=6.9
16 0 require Data::Decode::Encode::HTTP::Response::Parser;
17 0 return Data::Decode::Encode::HTTP::Response::Parser->new();
18 }
19  
20 0 ▶sub decode {
Subroutine decode: not called CC=7 SCAR=40.3
Pod documented
21 0 my ($self, $decoder, $string, $hints) = @_;
22  
23 0 ▶ if (! $hints->{response} || ! eval { $hints->{response}->isa('HTTP::Response') }) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($hints->{"response"} and eval { do { $hints->{"response"}->isa("HTTP::Response") } }) 0 0 0
Condition0%0/3
$hints->{"response"} and eval { do { $hints->{"response"}->isa("HTTP::Response") } }
!ll&&!rl&&r
000
MC/DC0%0/2
$hints->{"response"} and eval { do { $hints->{"response"}->isa("HTTP::Response") } }
$hints->{"response"} eval { do { $hints->{"response"}->isa("HTTP::Response") } }
Truth table0%0/3
A and B
A= $hints->{"response"}B= eval { do { $hints->{"response"}->isa("HTTP::Response") } }
ABresult
0X0
100
111
24 0 Data::Decode::Exception::Deferred->throw;
25 }
26 0 my $res = $hints->{response};
27  
28 0 my $decoded;
29 { # Attempt to decode from header information
30 0 my $from_header;
31 0 ▶ if ( ($res->header('Content-Type') || '') =~ /charset=([\w\-_]+)/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($res->header("Content-Type") || "") =~ /charset=([\w\-_]+)/i) 0 0 0
Condition0%0/2
$res->header('Content-Type') || ''
l!l
00
MC/DC0%0/1
$res->header('Content-Type') || ''
$res->header('Content-Type')
Truth table0%0/2
A
A= $res->header('Content-Type')
Aresult
11
00
32 0 $from_header = $1;
33 }
34 0 my $encoding = pick_encoding( $from_header );
35 0 $decoded = try_decode($encoding, $string);
36 0 ▶ return $decoded if $decoded;
Branch: 1 branch
BranchTrueFalseTotal
if $decoded 0 0 0
37 }
38  
39 { # Attempt to decode from meta information
40 0 my $p = $self->parser();
41 0 my $encoding = pick_encoding(
42 $p->extract_encodings( $res->content )
43 );
44 0 $decoded = try_decode($encoding, $string);
45 0 ▶ return $decoded if $decoded;
Branch: 1 branch
BranchTrueFalseTotal
if $decoded 0 0 0
46 }
47  
48 0 Data::Decode::Exception::Deferred->throw;
49 }
50  
51 4 1;
52  
53 __END__
↑ Summary Decode/Encode/HTTP/Response/Parser.pm »