File Coverage

blib/lib/WWW/Mechanize/DecodedContent.pm
Criterion Covered Total %
statement 9 16 56.2
branch 0 6 0.0
condition 0 3 0.0
subroutine 3 4 75.0
pod 0 1 0.0
total 12 30 40.0


line stmt bran cond sub pod time code
1             package WWW::Mechanize::DecodedContent;
2              
3 2     2   128491 use strict;
  2         6  
  2         114  
4             our $VERSION = '0.02';
5              
6 2     2   1400 use Encode ();
  2         16644  
  2         47  
7 2     2   2109 use HTTP::Response::Encoding;
  2         1052  
  2         319  
8              
9             sub WWW::Mechanize::decoded_content {
10 0     0 0   my $mech = shift;
11 0           my $content = $mech->content(@_);
12 0 0 0       return $content unless $mech->{ct} && $mech->{ct} =~ m!^text/!i;
13              
14             ## WWW::Mechanize 1.50 or over calls decoded_content() to get page
15 0 0         return $content if Encode::is_utf8($content);
16              
17 0 0         if (my $enc = $mech->res->encoding) {
18 0           return Encode::decode($enc, $content);
19             } else {
20 0           return;
21             }
22             }
23              
24             1;
25             __END__