Branch Coverage

blib/lib/LWP/UserAgent.pm
Criterion Covered Total %
branch 198 364 54.4


line true false branch
23 0 32 if ref $_[1] eq 'HASH'
32 32 0 unless defined $timeout
35 29 3 unless (exists $ssl_opts->{'verify_hostname'})
37 8 21 if (exists $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'}) { }
0 21 elsif ($ENV{'HTTPS_CA_FILE'} or $ENV{'HTTPS_CA_DIR'}) { }
49 31 1 unless (exists $ssl_opts->{'SSL_ca_file'})
50 0 31 if (my $ca_file = $ENV{'PERL_LWP_SSL_CA_FILE'} || $ENV{'HTTPS_CA_FILE'})
54 32 0 unless (exists $ssl_opts->{'SSL_ca_path'})
55 0 32 if (my $ca_path = $ENV{'PERL_LWP_SSL_CA_PATH'} || $ENV{'HTTPS_CA_DIR'})
60 32 0 unless defined $use_eval
62 32 0 unless defined $parse_head
66 32 0 unless defined $max_redirect
67 2 30 exists $cnf{'env_proxy'} ? :
68 1 31 exists $cnf{'no_proxy'} ? :
69 0 32 if ref $no_proxy ne 'ARRAY'
75 0 32 if $conn_cache and $keep_alive
82 32 0 unless defined $requests_redirectable
86 0 32 if $protocols_allowed and ref $protocols_allowed ne 'ARRAY'
88 0 32 if $protocols_forbidden and ref $protocols_forbidden ne 'ARRAY'
90 0 32 if $requests_redirectable and ref $requests_redirectable ne 'ARRAY'
93 0 1 if (%cnf and $^W)
114 2 30 defined $agent ? :
30 0 if defined $agent or not $def_headers or not $def_headers->header('User-Agent')
116 2 30 if $from
117 0 32 if $cookie_jar
119 2 30 if $env_proxy
121 1 31 if (exists $cnf{'proxy'})
123 0 1 if ref $cnf{'proxy'} ne 'ARRAY'
127 0 32 if $protocols_allowed
128 0 32 if $protocols_forbidden
130 1 31 if ($keep_alive)
133 1 31 if $conn_cache
151 70 0 unless ($response)
158 0 70 if ($x = $self->protocols_allowed) { }
1 69 elsif ($x = $self->protocols_forbidden) { }
159 0 0 if (grep((lc $_ eq $scheme), @$x)) { }
167 1 0 if (grep((lc $_ eq $scheme), @$x))
177 16 54 if ($proxy)
181 69 1 unless ($protocol)
189 0 1 if ($scheme eq 'https')
200 69 1 if (not $response and $self->{'use_eval'}) { }
0 1 elsif (not $response) { }
207 0 1 if (&blessed($error) and $error->isa('HTTP::Response')) { }
215 0 1 $status =~ s/^(\d\d\d)\s+// ? :
240 1 71 unless $request->method
242 0 71 unless $url
243 1 70 unless $url->scheme
247 70 0 if (my $def_headers = $self->{'def_headers'})
264 72 0 if (defined $request) { }
265 72 0 if (ref $request) { }
266 0 72 if ref $request eq 'ARRAY' or ref $request eq 'HASH' or not $request->can('method') or not $request->can('uri')
287 2 70 if ($error)
298 10 63 if $previous
300 2 71 if ($response->redirects >= $self->{'max_redirect'})
307 0 71 if (my $req = $self->run_handlers('response_redirect', $response))
313 6 65 if ($code == 301 or $code == 302 or $code == 303 or $code == 307) { }
8 57 elsif ($code == 401 or $code == 407) { }
323 0 0 if ($referral->header('Referer') and $request->uri->scheme eq 'https' and $referral->uri->scheme eq 'http')
332 0 6 if ($code == 303 or $code == 302)
336 0 0 unless ($method eq 'GET' or $method eq 'HEAD')
350 0 6 unless defined $referral_uri
356 0 6 unless $self->redirect_ok($referral, $response)
364 0 8 $proxy || $request->method eq 'CONNECT' ? :
369 0 8 unless (@challenges)
383 0 8 unless ($scheme =~ /^([a-z]+(?:-[a-z]+)*)$/)
393 2 6 unless (%{"${class}::";})
398 2 0 unless $req =~ /\.pm$/
404 0 2 if ($error)
405 0 0 if ($error =~ /^Can\'t locate/) { }
415 0 8 unless ($class->can('authenticate'))
444 4 6 if @_ and ref $_[0]
447 6 0 if (lc $k eq 'content')
453 2 8 if (defined $content and not ref $content)
467 11 2 unless defined $ct and $self->_has_raw_content(@parameters)
475 3 3 ref $parameters[1] ? :
493 3 4 ref $parameters[1] ? :
514 0 19 unless defined $args->[$i]
518 0 19 if ($args->[$i] eq ':content_cb') { }
0 19 elsif ($args->[$i] eq ':content_file') { }
0 19 elsif ($args->[$i] eq ':read_size_hint') { }
521 0 0 unless defined $arg
522 0 0 unless ref $arg and UNIVERSAL::isa($arg, 'CODE')
530 0 0 unless defined $arg
532 0 0 if ref $arg
534 0 0 unless length $arg
552 27 0 unless defined $arg
553 0 0 if defined $size
560 0 0 if $self->get('http://www.msftncsi.com/ncsi.txt')->content eq 'Microsoft NCSI'
561 0 0 if $self->get('http://www.apple.com')->content =~ m[Apple]
570 186 0 unless $self->{'show_progress'}
573 0 0 if ($status eq 'begin') { }
0 0 elsif ($status eq 'end') { }
0 0 elsif ($status eq 'tick') { }
584 0 0 if $t
593 0 0 if $p eq $self->{'progress_lastp'}
607 0 1 if (ref $scheme) { }
612 0 1 if $scheme =~ /\W/
618 0 1 if (ref $self and $x = $self->protocols_allowed) { }
1 0 elsif (ref $self and $x = $self->protocols_forbidden) { }
619 0 0 unless grep((lc $_ eq $scheme), @$x)
622 1 0 if grep((lc $_ eq $scheme), @$x)
627 0 0 if $x and $x ne 'LWP::Protocol::nogo'
651 0 6 unless $self->requests_redirectable
0 6 unless grep(($_ eq $method), @{[] unless $self->requests_redirectable;})
653 0 6 if ($new_request->uri->scheme eq 'file')
668 13 43 if (@_)
671 27 29 unless $old
672 15 14 if wantarray
679 0 4 if $proxy
692 13 4 if (@_ == 1)
696 2 2 if (@_)
700 2 0 unless @_
701 1 1 if (defined $v) { }
717 37 1 if (@_) { }
724 0 8 if $response->content_is_xhtml
725 8 0 if $] >= 5.008 and $HTML::Parser::VERSION >= 3.4
729 0 8 unless $parser
730 8 0 unless ($parser->parse($_[3]))
742 33 4 $flag ? :
754 1 0 if (@_)
756 0 1 if (ref $jar eq 'HASH')
763 0 1 $jar ? :
766 0 1 $jar ? :
774 0 60 if (@_)
775 0 0 unless @_ == 1 and $_[0]->can('header_field_names')
791 37 2 if (@_)
793 37 0 if ($agent) { }
794 2 35 if $agent =~ /\s+$/
813 1 0 if (@_)
815 1 0 if (ref $cache eq 'HASH')
837 56 0 unless exists $spec{'owner'}
840 48 8 if $cb
846 8 1 if @_ % 2
849 4 5 unless ($conf)
850 0 4 unless $init
854 9 0 unless exists $spec{'owner'}
856 6 3 if (not @h and $init)
857 6 0 if (ref $init eq 'CODE') { }
0 0 elsif (ref $init eq 'HASH') { }
870 0 3 wantarray ? :
875 56 0 if ($phase)
878 10 1 if $conf->empty
882 0 0 unless $self->{'handlers'}
889 47 3 if ($o->{'handlers'} and $o->{'handlers'}{$phase})
892 92 368 if (my $conf = $self->{'handlers'}{$phase})
900 141 273 if (defined wantarray)
903 0 0 if $ret
918 0 0 if @_ > 1 and $^W
934 0 4 unless $copy->{$k}
935 2 2 if (ref $copy->{$k} eq 'ARRAY') { }
2 0 elsif (ref $copy->{$k} eq 'HASH') { }
943 1 0 if ($self->{'def_headers'})
964 0 0 if (-e $file)
966 0 0 if ($mtime)
973 0 0 if ($response->header('X-Died'))
980 0 0 if ($response->is_success) { }
981 0 0 unless my(@stat) = stat $tmpfile
985 0 0 if (defined $content_length and $file_length < $content_length) { }
0 0 elsif (defined $content_length and $file_length > $content_length) { }
996 0 0 if (-e $file)
1001 0 0 unless rename $tmpfile, $file
1005 0 0 if (my $lm = $response->last_modified)
1020 0 23 if exists $req->{'proxy'}
1022 16 0 if ($ua->{'no_proxy'})
1023 16 0 if (my $host = eval { do { $req->uri->host } })
1025 0 0 if ($host =~ /\Q$domain\E$/)
1038 1 27 if (not @_ and ref $key eq 'ARRAY')
1039 0 1 unless @{$key;} % 2 == 0
1046 2 25 if ref $key
1048 0 25 unless $key =~ /^$URI::scheme_re\z/
1050 15 10 if (@_)
1052 14 1 if (defined $url and length $url)
1053 0 14 unless $url =~ /^$URI::scheme_re:/
1054 0 14 if $url =~ /^https?:/ and not $url =~ m[^https?://\w]
1069 0 205 if ($ENV{'REQUEST_METHOD'})
1072 0 0 if $k =~ /^HTTP_/
1073 0 0 if $k eq 'CGI_HTTP_PROXY'
1076 200 5 unless $k =~ /^(.*)_proxy$/
1078 0 5 if ($k eq 'no') { }
1083 2 3 unless $k =~ /^$URI::scheme_re\z/
1085 1 2 unless LWP::Protocol::implementor($k)
1094 0 0 if (@no) { }