Branch Coverage

blib/lib/Furl/HTTP.pm
Criterion Covered Total %
branch 144 292 49.3


line true false branch
41 0 33 @_ == 1 ? :
47 0 33 if (defined $args{'headers'})
51 0 0 if (lc $name eq 'connection') { }
126 3 2 if (@_ == 2) { }
136 3 0 if (lc $headers->[$i] eq $key)
147 20 9 if lc $headers->[$i] eq $key
154 11 1 if exists $INC{$file}
155 0 1 unless (eval { do { require $file } })
156 0 0 if ($@ =~ /^Can't locate/) { }
176 1 34 unless $url =~ m[\A ([a-z]+) # scheme :// (?: ([^/:\@?]+) # user : ([^/:\@?]+) # password @ )? ([^/:?]+) # host (?: : (\d+) )? # port (?: ( /? \? .* | / .*) )? # path_query \z]msx
196 1 0 ref $content eq 'ARRAY' ? :
0 1 ref $content eq 'HASH' ? :
213 4 4 if $ENV{'REQUEST_METHOD'}
226 23 45 if (defined(my $url = $args{'url'})) { }
231 0 45 unless (defined $host)
236 45 23 if (not defined $scheme) { }
6 34 elsif ($scheme ne 'http' and $scheme ne 'https') { }
242 62 0 $scheme eq 'http' ? :
245 1 61 unless (defined $port)
248 14 48 unless (defined $path_query)
252 3 59 unless (substr($path_query, 0, 1) eq "/")
257 0 62 if ($host =~ /[^A-Za-z0-9._-]/)
265 0 62 if ($proxy and $no_proxy)
266 0 0 if ($self->match_no_proxy($no_proxy, $host))
274 26 36 if (defined $sock)
275 2 24 if ($self->_do_select(0, $sock, 0)) { }
282 38 24 unless ($in_keepalive)
284 0 38 if ($proxy) { }
288 0 0 if (defined $proxy_user)
297 0 0 if ($scheme eq 'http') { }
300 0 0 if (defined $proxy_authorization)
308 38 0 if ($scheme eq 'http') { }
316 1 37 unless $sock
329 1 60 if $method eq "HEAD"
331 14 47 if (my $in_headers = $args{'headers'})
334 0 18 if (lc $name eq 'connection') { }
342 0 61 if (exists $self->{'proxy_authorization'})
345 6 55 if (defined $username)
354 0 61 if (defined $cookie_jar)
356 0 0 if ($args{'url'}) { }
365 0 0 exists $args{'port'} ? :
0 0 exists $args{'path_query'} ? :
373 3 58 if (defined $content)
375 0 3 if (not $content_is_fh and ref $content)
377 0 0 unless (defined _header_get(\@headers, "Content-Type"))
382 3 0 unless (defined _header_get(\@headers, "Content-Length"))
384 0 3 if ($content_is_fh) { }
386 0 0 unless $_[0]
405 1 60 $port == $default_port ? :
408 0 61 $proxy && $scheme eq 'http' ? :
418 0 61 unless $self->write_all($sock, $p, $timeout_at)
422 1 60 if ($self->{'capture_request'})
426 3 58 if (defined $content)
427 0 3 if ($content_is_fh) { }
432 0 0 if (not defined $ret) { }
0 0 elsif ($ret == 0) { }
437 0 0 unless $self->write_all($sock, $buf, $timeout_at)
442 0 0 if ($self->{'capture_request'})
447 0 3 if (length $content > 0)
448 0 0 unless $self->write_all($sock, $content, $timeout_at)
453 0 0 if ($self->{'capture_request'})
477 3 210 if (not $n) { }
478 0 3 if ($in_keepalive and length $buf == 0 and defined $n || $! == 104 || 0)
483 3 0 !defined($n) ? :
494 0 210 if ($ret == -1) { }
147 63 elsif ($ret == -2) { }
504 5 58 if (int $res_status / 100 eq 1)
518 0 58 if ($special_headers->{'location'})
519 0 0 defined $args{'max_redirects'} ? :
524 58 0 unless ($do_redirect)
525 0 58 if (my $fh = $args{'write_file'}) { }
0 58 elsif (my $coderef = $args{'write_code'}) { }
534 0 58 if (exists $COMPRESSED{$special_headers->{'content-encoding'}})
542 1 57 if (defined $content_length and not $content_length =~ /\A[0-9]+\z/)
546 50 6 unless ($method eq "HEAD" or $res_status < 200 and $res_status >= 100 or $res_status == 204 or $res_status == 304)
551 7 43 if ($chunked) { }
556 2 41 if (ref $res_content or not defined $content_length) { }
566 2 48 if (@err)
572 54 1 if (lc $connection_header eq "keep-alive")
574 10 44 $res_minor_version == 0 ? :
44 0 if ($res_minor_version == 0 ? $connection eq "keep-alive" : $connection ne "close" and defined $content_length || $chunked)
586 0 55 if (defined $cookie_jar)
587 0 0 defined $username && defined $password ? :
595 0 0 unless ref $cookies
601 0 55 if ($do_redirect)
603 0 0 unless ($location =~ m[^[a-z0-9]+://])
617 0 0 $res_status =~ /^30[178]$/ ? :
627 0 55 if (ref $res_content)
643 0 38 if $timeout <= 0
646 1 37 unless $sock_addr
649 0 37 unless socket $sock, Socket::sockaddr_family($sock_addr), 1, 0
653 0 37 if (CORE::connect $sock, $sock_addr) { }
37 0 elsif ($! == 115 or 0) { }
656 0 37 unless $self->do_select(1, $sock, $timeout_at)
660 0 0 if ($! == 4 and not $self->{'stop_if'}->())
671 1 37 if ($self->{'get_address'})
675 1 36 unless my $iaddr = $self->{'inet_aton'}->($host, $timeout)
683 0 0 unless (exists $ssl_opts->{'SSL_verify_mode'})
686 0 0 unless (exists $ssl_opts->{'SSL_verifycn_scheme'})
690 0 0 if ($ssl_opts->{'SSL_verify_mode'})
691 0 0 unless (exists $ssl_opts->{'SSL_ca_file'} or exists $ssl_opts->{'SSL_ca_path'})
707 0 0 unless $sock
711 0 0 if $timeout <= 0
715 0 0 unless "IO::Socket::SSL"->start_SSL($sock, "PeerHost", $host, "PeerPort", $port, "Timeout", $timeout, %$ssl_opts)
733 0 0 if (defined $proxy_authorization)
737 0 0 unless $self->write_all($sock, $p, $timeout_at)
743 0 0 if (not defined $read) { }
0 0 elsif ($read == 0) { }
0 0 elsif (not $buf =~ m[^HTTP/1\.[0-9] 200 .+\015\012]) { }
752 0 0 if $timeout_at <= 0
756 0 0 unless (exists $ssl_opts->{'SSL_verifycn_name'})
760 0 0 unless "IO::Socket::SSL"->start_SSL($sock, "PeerHost", $host, "PeerPort", $port, "Timeout", $timeout, %$ssl_opts)
775 2082 513 if (my($header, $next_len) = $buf =~ /\A ( # header ( [0-9a-fA-F]+ ) # next_len (hex number) (?:; $HTTP_TOKEN = (?: $HTTP_TOKEN | $HTTP_QUOTED_STRING ) )* # optional chunk-extensions [ ]* # www.yahoo.com adds spaces here. # Is this valid? \015\012 # CR+LF ) /mosx)
794 6 2076 if ($next_len == 0)
802 0 1290 unless ($n)
803 0 0 !defined($n) ? :
812 2076 0 if (length $buf > 0)
819 1 512 unless ($n)
820 0 1 !defined($n) ? :
838 1 1 if (not defined $n) { }
1 0 elsif (not $n) { }
841 1 0 unless defined $res_content_length
858 0 29 unless ($n)
859 0 0 !defined($n) ? :
875 0 91 if $timeout_at > $inactivity_timeout_at
880 1 94 if ($timeout <= 0)
885 87 7 if $nfound > 0
886 3 3 if $nfound == -1 and $! == 4 and $self->{'stop_if'}->()
897 37 83 if ($is_write) { }
915 2043 54 if defined($ret = sysread($sock, $$buf, $len, $off))
917 54 0 if ($! == 11 or $! == 11 or 0) { }
0 0 elsif ($! == 4) { }
920 0 0 if $self->{'stop_if'}->()
926 4 50 unless $self->do_select(0, $sock, $timeout_at)
936 61 0 if defined($ret = syswrite($sock, $buf, $len, $off))
938 0 0 if ($! == 11 or $! == 11 or 0) { }
0 0 elsif ($! == 4) { }
941 0 0 if $self->{'stop_if'}->()
946 0 0 unless $self->do_select(1, $sock, $timeout_at)
955 0 61 unless my $ret = $self->write_timeout($sock, $buf, $len, $off, $timeout_at)
976 3 1 $! != 0 ? :
982 0 37 unless setsockopt $sock, 6, 1, 1
991 0 37 unless my $flags = fcntl($sock, 3, 0)
993 0 37 unless $flags = fcntl($sock, 4, $flags | 2048)
1014 0 0 if ($no_proxy eq '*') { }
1019 0 0 if ($host =~ /\Q$pat\E$/)