Branch Coverage

blib/lib/Furl/HTTP.pm
Criterion Covered Total %
branch 138 292 47.2


line true false branch
41 0 32 @_ == 1 ? :
47 0 32 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 0 0 ref $content eq 'ARRAY' ? :
0 0 ref $content eq 'HASH' ? :
213 4 4 if $ENV{'REQUEST_METHOD'}
226 23 44 if (defined(my $url = $args{'url'})) { }
231 0 44 unless (defined $host)
236 44 23 if (not defined $scheme) { }
6 34 elsif ($scheme ne 'http' and $scheme ne 'https') { }
242 61 0 $scheme eq 'http' ? :
245 1 60 unless (defined $port)
248 13 48 unless (defined $path_query)
252 3 58 unless (substr($path_query, 0, 1) eq '/')
257 0 61 if ($host =~ /[^A-Za-z0-9._-]/)
265 0 61 if ($proxy and $no_proxy)
266 0 0 if ($self->match_no_proxy($no_proxy, $host))
274 26 35 if (defined $sock)
275 2 24 if ($self->_do_select(0, $sock, 0)) { }
282 37 24 unless ($in_keepalive)
284 0 37 if ($proxy) { }
288 0 0 if (defined $proxy_user)
297 0 0 if ($scheme eq 'http') { }
300 0 0 if (defined $proxy_authorization)
308 37 0 if ($scheme eq 'http') { }
316 1 36 unless $sock
329 1 59 if $method eq 'HEAD'
331 14 46 if (my $in_headers = $args{'headers'})
334 0 18 if (lc $name eq 'connection') { }
342 0 60 if (exists $self->{'proxy_authorization'})
345 6 54 if (defined $username)
354 0 60 if (defined $cookie_jar)
356 0 0 if ($args{'url'}) { }
365 0 0 exists $args{'port'} ? :
0 0 exists $args{'path_query'} ? :
373 3 57 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 59 $port == $default_port ? :
408 0 60 $proxy && $scheme eq 'http' ? :
418 0 60 unless $self->write_all($sock, $p, $timeout_at)
422 1 59 if ($self->{'capture_request'})
426 3 57 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 209 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 209 if ($ret == -1) { }
147 62 elsif ($ret == -2) { }
504 5 57 if (int $res_status / 100 eq 1)
518 0 57 if ($special_headers->{'location'})
519 0 0 defined $args{'max_redirects'} ? :
524 57 0 unless ($do_redirect)
525 0 57 if (my $fh = $args{'write_file'}) { }
0 57 elsif (my $coderef = $args{'write_code'}) { }
534 0 57 if (exists $COMPRESSED{$special_headers->{'content-encoding'}})
542 1 56 if (defined $content_length and not $content_length =~ /\A[0-9]+\z/)
546 49 6 unless ($method eq 'HEAD' or $res_status < 200 and $res_status >= 100 or $res_status == 204 or $res_status == 304)
551 7 42 if ($chunked) { }
556 1 41 if (ref $res_content or not defined $content_length) { }
566 1 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 37 if $timeout <= 0
646 1 36 unless $sock_addr
649 0 36 unless socket $sock, Socket::sockaddr_family($sock_addr), 1, 0
653 0 36 if (CORE::connect $sock, $sock_addr) { }
36 0 elsif ($! == 115 or 0) { }
656 0 36 unless $self->do_select(1, $sock, $timeout_at)
660 0 0 if ($! == 4 and not $self->{'stop_if'}->())
671 1 36 if ($self->{'get_address'})
675 1 35 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 0 unless ($n)
839 1 0 unless defined $res_content_length
840 0 0 !defined($n) ? :
860 0 26 unless ($n)
861 0 0 !defined($n) ? :
877 0 94 if $timeout_at > $inactivity_timeout_at
882 0 97 if ($timeout <= 0)
887 91 6 if $nfound > 0
888 3 3 if $nfound == -1 and $! == 4 and $self->{'stop_if'}->()
899 36 87 if ($is_write) { }
917 2039 58 if defined($ret = sysread($sock, $$buf, $len, $off))
919 58 0 if ($! == 11 or $! == 11 or 0) { }
0 0 elsif ($! == 4) { }
922 0 0 if $self->{'stop_if'}->()
928 3 55 unless $self->do_select(0, $sock, $timeout_at)
938 60 0 if defined($ret = syswrite($sock, $buf, $len, $off))
940 0 0 if ($! == 11 or $! == 11 or 0) { }
0 0 elsif ($! == 4) { }
943 0 0 if $self->{'stop_if'}->()
948 0 0 unless $self->do_select(1, $sock, $timeout_at)
957 0 60 unless my $ret = $self->write_timeout($sock, $buf, $len, $off, $timeout_at)
978 3 0 $! != 0 ? :
984 0 36 unless setsockopt $sock, 6, 1, 1
993 0 36 unless my $flags = fcntl($sock, 3, 0)
995 0 36 unless $flags = fcntl($sock, 4, $flags | 2048)
1016 0 0 if ($no_proxy eq '*') { }
1021 0 0 if ($host =~ /\Q$pat\E$/)