| 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
Condition0%0/3
$hints->{"response"} and eval {
do {
$hints->{"response"}->isa("HTTP::Response")
}
}
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")
}
}
| |||||||||||||||||||||||||||||
| 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
Condition0%0/2
$res->header('Content-Type') || ''
MC/DC0%0/1
$res->header('Content-Type') || ''
$res->header('Content-Type')
Truth table0%0/2
A
A= $res->header('Content-Type')
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | Data::Decode::Exception::Deferred->throw; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 4 | 1; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||||||||||