Branch Coverage

blib/lib/LWP/UserAgent.pm
Criterion Covered Total %
branch 202 366 55.1


line true false branch
23 0 34 if ref $_[1] eq 'HASH'
32 34 0 unless defined $timeout
35 31 3 unless (exists $ssl_opts->{'verify_hostname'})
37 8 23 if (exists $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'}) { }
0 23 elsif ($ENV{'HTTPS_CA_FILE'} or $ENV{'HTTPS_CA_DIR'}) { }
49 33 1 unless (exists $ssl_opts->{'SSL_ca_file'})
50 0 33 if (my $ca_file = $ENV{'PERL_LWP_SSL_CA_FILE'} || $ENV{'HTTPS_CA_FILE'})
54 34 0 unless (exists $ssl_opts->{'SSL_ca_path'})
55 0 34 if (my $ca_path = $ENV{'PERL_LWP_SSL_CA_PATH'} || $ENV{'HTTPS_CA_DIR'})
60 34 0 unless defined $use_eval
62 34 0 unless defined $parse_head
64 33 1 unless defined $send_te
68 34 0 unless defined $max_redirect
69 2 32 exists $cnf{'env_proxy'} ? :
70 1 33 exists $cnf{'no_proxy'} ? :
71 0 34 if ref $no_proxy ne 'ARRAY'
77 0 34 if $conn_cache and $keep_alive
84 34 0 unless defined $requests_redirectable
88 0 34 if $protocols_allowed and ref $protocols_allowed ne 'ARRAY'
90 0 34 if $protocols_forbidden and ref $protocols_forbidden ne 'ARRAY'
92 0 34 if $requests_redirectable and ref $requests_redirectable ne 'ARRAY'
95 0 1 if (%cnf and $^W)
117 2 32 defined $agent ? :
32 0 if defined $agent or not $def_headers or not $def_headers->header('User-Agent')
119 2 32 if $from
120 0 34 if $cookie_jar
122 2 32 if $env_proxy
124 1 33 if (exists $cnf{'proxy'})
126 0 1 if ref $cnf{'proxy'} ne 'ARRAY'
130 0 34 if $protocols_allowed
131 0 34 if $protocols_forbidden
133 1 33 if ($keep_alive)
136 1 33 if $conn_cache
154 71 2 unless ($response)
161 0 71 if ($x = $self->protocols_allowed) { }
1 70 elsif ($x = $self->protocols_forbidden) { }
162 0 0 if (grep((lc $_ eq $scheme), @$x)) { }
170 1 0 if (grep((lc $_ eq $scheme), @$x))
180 16 55 if ($proxy)
184 70 1 unless ($protocol)
192 0 1 if ($scheme eq 'https')
203 70 1 if (not $response and $self->{'use_eval'}) { }
0 1 elsif (not $response) { }
210 0 2 if (&blessed($error) and $error->isa('HTTP::Response')) { }
218 0 2 $status =~ s/^(\d\d\d)\s+// ? :
243 1 74 unless $request->method
245 0 74 unless $url
246 1 73 unless $url->scheme
250 73 0 if (my $def_headers = $self->{'def_headers'})
267 75 0 if (defined $request) { }
268 75 0 if (ref $request) { }
269 0 75 if ref $request eq 'ARRAY' or ref $request eq 'HASH' or not $request->can('method') or not $request->can('uri')
290 2 73 if ($error)
301 10 66 if $previous
303 2 74 if ($response->redirects >= $self->{'max_redirect'})
310 0 74 if (my $req = $self->run_handlers('response_redirect', $response))
316 6 68 if ($code == 301 or $code == 302 or $code == 303 or $code == 307) { }
8 60 elsif ($code == 401 or $code == 407) { }
326 0 0 if ($referral->header('Referer') and $request->uri->scheme eq 'https' and $referral->uri->scheme eq 'http')
335 0 6 if ($code == 303 or $code == 302)
339 0 0 unless ($method eq 'GET' or $method eq 'HEAD')
353 0 6 unless defined $referral_uri
359 0 6 unless $self->redirect_ok($referral, $response)
367 0 8 $proxy || $request->method eq 'CONNECT' ? :
372 0 8 unless (@challenges)
386 0 8 unless ($scheme =~ /^([a-z]+(?:-[a-z]+)*)$/)
396 2 6 unless (%{"${class}::";})
401 2 0 unless $req =~ /\.pm$/
407 0 2 if ($error)
408 0 0 if ($error =~ /^Can\'t locate/) { }
418 0 8 unless ($class->can('authenticate'))
447 4 6 if @_ and ref $_[0]
450 6 0 if (lc $k eq 'content')
456 2 8 if (defined $content and not ref $content)
470 11 2 unless defined $ct and $self->_has_raw_content(@parameters)
478 3 3 ref $parameters[1] ? :
496 3 4 ref $parameters[1] ? :
517 0 19 unless defined $args->[$i]
521 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') { }
524 0 0 unless defined $arg
525 0 0 unless ref $arg and UNIVERSAL::isa($arg, 'CODE')
533 0 0 unless defined $arg
535 0 0 if ref $arg
537 0 0 unless length $arg
555 29 0 unless defined $arg
556 0 0 if defined $size
563 0 0 if $self->get('http://www.msftncsi.com/ncsi.txt')->content eq 'Microsoft NCSI'
564 0 0 if $self->get('http://www.apple.com')->content =~ m[Apple]
573 192 0 unless $self->{'show_progress'}
576 0 0 if ($status eq 'begin') { }
0 0 elsif ($status eq 'end') { }
0 0 elsif ($status eq 'tick') { }
587 0 0 if $t
596 0 0 if $p eq $self->{'progress_lastp'}
610 0 1 if (ref $scheme) { }
615 0 1 if $scheme =~ /\W/
621 0 1 if (ref $self and $x = $self->protocols_allowed) { }
1 0 elsif (ref $self and $x = $self->protocols_forbidden) { }
622 0 0 unless grep((lc $_ eq $scheme), @$x)
625 1 0 if grep((lc $_ eq $scheme), @$x)
630 0 0 if $x and $x ne 'LWP::Protocol::nogo'
654 0 6 unless $self->requests_redirectable
0 6 unless grep(($_ eq $method), @{[] unless $self->requests_redirectable;})
656 0 6 if ($new_request->uri->scheme eq 'file')
671 13 43 if (@_)
674 27 29 unless $old
675 15 14 if wantarray
682 0 4 if $proxy
696 13 4 if (@_ == 1)
700 2 2 if (@_)
704 2 0 unless @_
705 1 1 if (defined $v) { }
721 39 1 if (@_) { }
728 0 8 if $response->content_is_xhtml
729 8 0 if $] >= 5.008 and $HTML::Parser::VERSION >= 3.4
733 0 8 unless $parser
734 8 0 unless ($parser->parse($_[3]))
746 35 4 $flag ? :
758 1 0 if (@_)
760 0 1 if (ref $jar eq 'HASH')
767 0 1 $jar ? :
770 0 1 $jar ? :
778 0 62 if (@_)
779 0 0 unless @_ == 1 and $_[0]->can('header_field_names')
795 39 2 if (@_)
797 39 0 if ($agent) { }
798 2 37 if $agent =~ /\s+$/
817 1 0 if (@_)
819 1 0 if (ref $cache eq 'HASH')
841 58 0 unless exists $spec{'owner'}
844 50 8 if $cb
850 8 1 if @_ % 2
853 4 5 unless ($conf)
854 0 4 unless $init
858 9 0 unless exists $spec{'owner'}
860 6 3 if (not @h and $init)
861 6 0 if (ref $init eq 'CODE') { }
0 0 elsif (ref $init eq 'HASH') { }
874 0 3 wantarray ? :
879 58 0 if ($phase)
882 10 1 if $conf->empty
886 0 0 unless $self->{'handlers'}
893 47 3 if ($o->{'handlers'} and $o->{'handlers'}{$phase})
896 95 380 if (my $conf = $self->{'handlers'}{$phase})
908 147 282 if (defined wantarray)
911 2 0 if $ret
926 0 0 if @_ > 1 and $^W
942 0 4 unless $copy->{$k}
943 2 2 if (ref $copy->{$k} eq 'ARRAY') { }
2 0 elsif (ref $copy->{$k} eq 'HASH') { }
951 1 0 if ($self->{'def_headers'})
972 0 0 if (-e $file)
974 0 0 if ($mtime)
981 0 0 if ($response->header('X-Died'))
988 0 0 if ($response->is_success) { }
989 0 0 unless my(@stat) = stat $tmpfile
993 0 0 if (defined $content_length and $file_length < $content_length) { }
0 0 elsif (defined $content_length and $file_length > $content_length) { }
1004 0 0 if (-e $file)
1009 0 0 unless rename $tmpfile, $file
1013 0 0 if (my $lm = $response->last_modified)
1028 0 23 if exists $req->{'proxy'}
1030 16 0 if ($ua->{'no_proxy'})
1031 16 0 if (my $host = eval { do { $req->uri->host } })
1033 0 0 if ($host =~ /\Q$domain\E$/)
1046 1 27 if (not @_ and ref $key eq 'ARRAY')
1047 0 1 unless @{$key;} % 2 == 0
1054 2 25 if ref $key
1056 0 25 unless $key =~ /^$URI::scheme_re\z/
1058 15 10 if (@_)
1060 14 1 if (defined $url and length $url)
1061 0 14 unless $url =~ /^$URI::scheme_re:/
1062 0 14 if $url =~ /^https?:/ and not $url =~ m[^https?://\w]
1077 0 211 if ($ENV{'REQUEST_METHOD'})
1080 0 0 if $k =~ /^HTTP_/
1081 0 0 if $k eq 'CGI_HTTP_PROXY'
1084 206 5 unless $k =~ /^(.*)_proxy$/
1086 0 5 if ($k eq 'no') { }
1091 2 3 unless $k =~ /^$URI::scheme_re\z/
1093 1 2 unless LWP::Protocol::implementor($k)
1102 0 0 if (@no) { }