Branch Coverage

lib/HTTP/Promise.pm
Criterion Covered Total %
branch 0 540 0.0


line true false branch
107 0 0 unless $self->SUPER::init(@_)
109 0 0 if ($headers) { }
111 0 0 unless ($self->connection_header)
114 0 0 if ($headers->exists("connection"))
123 0 0 unless $self->default_headers("HTTP::Promise::Headers"->new)
145 0 0 if ($self->{'default_headers'})
171 0 0 if ($self->use_promise) { }
208 0 0 if (&Scalar::Util::blessed($_[0]) and $_[0]->isa('HTTP::Promise')) { }
219 0 0 if ($_[$i] eq "method")
226 0 0 unless $meth =~ /^$HTTP::Promise::Request::KNOWN_METHODS_I$/i
240 0 0 if ($self->use_promise) { }
271 0 0 if ($self->use_promise) { }
308 0 0 if ($self->_is_object($scheme)) { }
310 0 0 unless $scheme->can("scheme")
315 0 0 if $scheme =~ /\W/
318 0 0 if $scheme eq "http" or $scheme eq "https"
349 0 0 if ($self->use_promise) { }
354 0 0 unless defined $file and length $file
364 0 0 unless $self->prepare_headers($request)
375 0 0 if ($file->exists)
379 0 0 if ($mtime)
391 0 0 unless $tmpfile->touch
395 0 0 if ($response->header("X-Died"))
407 0 0 if ($response->is_success) { }
410 0 0 unless $body
414 0 0 unless $body
419 0 0 unless $body
426 0 0 unless $body
434 0 0 unless my $stat = $tmpfile->stat
442 0 0 if (defined $content_length and $file_length < $content_length) { }
0 0 elsif (defined $content_length and $file_length > $content_length) { }
472 0 0 if (defined(my $umask = umask()))
475 0 0 unless $file->chmod($mode)
483 0 0 if (my $lm = $response->last_modified)
486 0 0 unless ($file->utime($lm, $lm))
487 0 0 if $self->_warnings_is_enabled
498 0 0 defined $self->{'serialiser'} ? :
502 0 0 unless defined $file and length $file
512 0 0 unless $self->prepare_headers($request)
515 0 0 if ($file->exists)
519 0 0 if ($mtime)
528 0 0 unless $tmpfile->touch
532 0 0 if ($response->header("X-Died"))
544 0 0 if ($response->is_success) { }
547 0 0 unless $body
551 0 0 unless $body
556 0 0 unless $body
563 0 0 unless $body
571 0 0 unless my $stat = $tmpfile->stat
579 0 0 if (defined $content_length and $file_length < $content_length) { }
0 0 elsif (defined $content_length and $file_length > $content_length) { }
609 0 0 if (defined(my $umask = umask()))
612 0 0 unless $file->chmod($mode)
620 0 0 if (my $lm = $response->last_modified)
623 0 0 unless ($file->utime($lm, $lm))
624 0 0 if $self->_warnings_is_enabled
641 0 0 unless $self->_load_class("HTTP::Promise::Headers")
653 0 0 if ($self->use_promise) { }
684 0 0 if ($self->use_promise) { }
715 0 0 if ($self->use_promise) { }
747 0 0 unless $self->_is_a($req, "HTTP::Promise::Request")
749 0 0 unless $h
750 0 0 unless ($req->protocol)
764 0 0 if (defined $ua and not $h->user_agent)
769 0 0 unless ($h->accept)
775 0 0 if (not $h->accept_encoding and $ae ne "none")
777 0 0 unless $self->_load_class("HTTP::Promise::Stream")
779 0 0 if (not $ae->is_empty and $ae ne 'all' and $ae ne 'auto') { }
790 0 0 unless ($h->accept_language or $self->accept_language->is_empty)
797 0 0 unless $pref == "0.1"
802 0 0 if (not defined $h->dnt and defined $dnt)
804 0 0 $dnt ? :
808 0 0 if ($req->uri->scheme eq "http" and !defined($upgrade_ssl) || $upgrade_ssl)
822 0 0 if ($self->use_promise) { }
856 0 0 if ($self->use_promise) { }
878 0 0 unless $req
879 0 0 if exists $opts->{'use_content_file'}
892 0 0 unless $self->_is_a($req, "HTTP::Promise::Request")
901 0 0 if (not $uri->scheme) { }
0 0 elsif ($uri->scheme ne 'http' and $uri->scheme ne 'https') { }
909 0 0 $uri->scheme eq 'http' ? :
912 0 0 if (not $uri->can('port') && defined $uri->port && length $uri->port) { }
920 0 0 unless length $uri->path
925 0 0 if (my $local_host = $self->local_host)
929 0 0 if (my $local_port = $self->local_port)
936 0 0 if ($proxy and $no_proxy)
938 0 0 if ($self->_match_no_proxy($no_proxy, $p->{'host'}))
947 0 0 if (defined $sock and &Scalar::Util::openhandle($sock))
951 0 0 if ($io->make_select('write', 0, 'timeout', 0)) { }
961 0 0 unless ($p->{'in_keepalive'})
963 0 0 if ($proxy) { }
966 0 0 unless $self->_is_a($proxy, "URI")
970 0 0 if (defined $proxy_user and length $proxy_user)
972 0 0 unless $self->_load_class("URI::Escape::XS")
975 0 0 unless $self->_load_class("Crypt::Misc")
978 0 0 if ($uri->scheme eq 'http') { }
989 0 0 if (defined $proxy_authorization)
1012 0 0 if ($uri->scheme eq 'http') { }
1049 0 0 if ($body_len != $ct_len)
1051 0 0 if warnings::enabled(ref $self)
1056 0 0 unless $entity->print_body($io)
1067 0 0 unless ($connection_header)
1069 0 0 if (uc $method eq 'HEAD') { }
0 0 elsif ($req->version and $req->version > 1) { }
1088 0 0 if ($self->_is_array($in_headers))
1093 0 0 if (lc $name eq 'connection') { }
1105 0 0 if (my $pa = $self->proxy_authorization)
1110 0 0 if (defined $userinfo and length $userinfo)
1113 0 0 unless $self->_load_class("URI::Escape")
1116 0 0 unless $self->_load_class("Crypt::Misc")
1122 0 0 if (defined $cookie_jar)
1124 0 0 unless $cookie_jar->add_request_header($req)
1129 0 0 if (defined $body and $body)
1131 0 0 if ($body->isa("HTTP::Promise::Body::Form") and !$headers->exists('Content-Type') || $headers->content_type->is_empty)
1136 0 0 unless ($headers->exists("Content-Length"))
1144 0 0 $uri->port == $default_port ? :
1148 0 0 if (defined $expect_threshold)
1150 0 0 if ($self->_is_integer($expect_threshold)) { }
1160 0 0 if ($req->version and $req->version > 1 and defined $expect_threshold and defined $body and $body->length > $expect_threshold)
1172 0 0 if (not defined $bytes) { }
0 0 elsif (not $bytes) { }
1186 0 0 if (not $headers->expect and defined $body and $body)
1189 0 0 unless defined $bytes
1209 0 0 if (not defined $n or $n == 0)
1211 0 0 defined $n ? :
1212 0 0 if ($p->{'in_keepalive'} and (length $buff // 0) == 0 and not $opts->{'total_attempts'} and defined $n || $code == 104 || $HTTP::Promise::IS_WIN32 && $code == 103) { }
0 0 elsif (not length $buff) { }
0 0 elsif (not defined $n) { }
1236 0 0 if (not defined $def) { }
1239 0 0 if ($parser->error->code == 425) { }
0 0 elsif ($parser->error->code == 400 and length $buff > $max) { }
1255 0 0 unless $self->_is_integer($def->{'length'})
1256 0 0 if $def->{'length'} > length $buff
1260 0 0 if length $buff
1264 0 0 unless defined $trash
1265 0 0 if ($req->headers->exists("Expect"))
1270 0 0 if ($def->{'code'} == 100) { }
0 0 elsif ($def->{'code'} == 417) { }
1274 0 0 unless defined $bytes
1302 0 0 $headers->exists('Content-Encoding') && !$headers->content_encoding->is_empty ? :
1308 0 0 unless $self->_load_class("HTTP::Promise::Response")
1322 0 0 if ($headers->exists("Location"))
1326 0 0 defined $opts->{'max_redirect'} && $opts->{'max_redirect'} =~ /^\d+$/ ? :
1339 0 0 if (defined $content_length and length $content_length and not $content_length =~ /^\d+$/)
1344 0 0 if $self->_warnings_is_enabled
1348 0 0 unless ($req->method eq "HEAD" or $def->{'code'} >= 100 and $def->{'code'} < 200 or $def->{'code'} == 204 or $def->{'code'} == 304)
1353 0 0 if ($chunked) { }
1369 0 0 unless defined $body
1375 0 0 if (defined $connection_header and lc $connection_header eq "keep-alive")
1379 0 0 $def->{'version'} > 1 ? :
0 0 if ($def->{'version'} > 1 ? $connection ne "close" : $connection eq "keep-alive" and defined $content_length || $chunked)
1385 0 0 unless $self->_pool->push($uri->host, $uri->port, $sock)
1395 0 0 if (defined $cookie_jar)
1397 0 0 unless $cookie_jar->add_response_header($resp)
1401 0 0 if ($do_redirect)
1404 0 0 unless ($location =~ m[^[a-zA-Z][a-zA-Z0-9]+://])
1420 0 0 unless ($def->{'code'} =~ /^30[178]$/)
1425 0 0 if $max_redirect > 0
1436 0 0 if ($ent->body and $type =~ m[^multipart/]i)
1474 0 0 if ($self->use_promise) { }
1479 0 0 unless $req
1483 0 0 if exists $opts->{'use_content_file'}
1491 0 0 unless $req
1492 0 0 if exists $opts->{'use_content_file'}
1521 0 0 if (@_)
1523 0 0 unless $self->_is_a($_[0], ["DateTime", "Module::Generic::DateTime"])
1527 0 0 if (not defined $dt) { }
0 0 elsif ($dt->isa('Module::Generic::DateTime')) { }
1570 0 0 if (scalar @_ and defined $_[0] and $self->_is_array($_[0]) || ref $_[0] eq 'HASH' || $self->_is_a($_[0], 'HTTP::Promise::Body::Form') || $self->_is_a($_[0], 'HTTP::Promise::Body::Form::Data')) { }
0 0 elsif (scalar @_ and @_ % 2 and defined $_[-1] and $self->_is_array($_[-1]) || ref $_[-1] eq 'HASH' || $self->_is_a($_[-1], 'HTTP::Promise::Body::Form') || $self->_is_a($_[-1], 'HTTP::Promise::Body::Form::Data')) { }
1597 0 0 if (lc $k eq 'content') { }
0 0 elsif (lc $k eq 'query') { }
1604 0 0 if (ref $v eq 'HASH' or $self->_is_array($v)) { }
0 0 elsif (not ref $v or ref $v and overload::Method($v, '""')) { }
1612 0 0 if ($@)
1632 0 0 if (not $ct and defined $content) { }
0 0 elsif ($ct and $ct eq 'form-data') { }
1641 0 0 if (defined $ct and length "$ct")
1644 0 0 unless defined $obj
1649 0 0 if (ref $content) { }
0 0 elsif (defined $content and length $content) { }
1652 0 0 if (lc substr("$type", 0, 19) eq 'multipart/form-data') { }
0 0 elsif (lc $type eq 'application/x-www-form-urlencoded' and &Scalar::Util::reftype($content) eq 'ARRAY' || ref $content eq 'HASH' || $self->_is_a($content, 'HTTP::Promise::Body::Form')) { }
0 0 elsif ($self->_is_a($content, 'HTTP::Promise::Body')) { }
0 0 elsif ($self->_is_a($content, 'Module::Generic::File')) { }
0 0 elsif (overload::Method($content, '""')) { }
1654 0 0 unless ($obj->boundary)
1659 0 0 if ($self->_is_a($content, "HTTP::Promise::Body::Form::Data"))
1665 0 0 if ($self->_is_a($content, 'HTTP::Promise::Body::Form')) { }
0 0 elsif ($self->_is_array($content)) { }
0 0 elsif (ref $content eq 'HASH') { }
1681 0 0 unless $self->_load_class("HTTP::Promise::Body::Form::Data")
1691 0 0 unless $self->_load_class("HTTP::Promise::Body::Form::Data")
1712 0 0 if ($self->_is_a($content, 'HTTP::Promise::Body::Form')) { }
1719 0 0 unless $self->_load_class("HTTP::Promise::Body::Form")
1757 0 0 if defined $obj and not $orig_ct
1758 0 0 if (defined $content) { }
0 0 elsif ($ct) { }
1761 0 0 if (my $encodings = $req->headers->content_encoding)
1763 0 0 unless $ent->is_encoded
1788 0 0 if (lc $k eq 'content' or lc $k eq 'query') { }
1790 0 0 if (ref $v eq 'HASH' or $self->_is_array($v)) { }
0 0 elsif (not ref $v or ref $v and overload::Method($v, '""')) { }
1798 0 0 if ($@)
1809 0 0 if $self->_warnings_is_enabled
1828 0 0 if ($no_proxy eq '*') { }
0 0 elsif ($self->_is_array($no_proxy)) { }
1837 0 0 if ($host =~ /\Q$pat\E$/)
1856 0 0 unless $self->_is_a($headers, "HTTP::Promise::Headers")
1858 0 0 unless $self->_is_a($ent, "HTTP::Promise::Entity")
1860 0 0 unless $self->_is_a($reader, "HTTP::Promise::IO")
1879 0 0 unless $self->_load_class("HTTP::Promise::MIME")
1882 0 0 unless defined $ext
1889 0 0 if (defined $len) { }
1893 0 0 if ($len > $max_in_memory or $self->use_content_file) { }
1900 0 0 if $chunk_size > $len
1904 0 0 unless defined $bytes_out
1906 0 0 if $total_bytes < $len and $total_bytes + $chunk_size > $len
1908 0 0 if $total_bytes == $len
1911 0 0 unless defined $bytes
1917 0 0 if $chunk_size > $len
1922 0 0 if $total_bytes < $len and $total_bytes + $chunk_size > $len
1924 0 0 if $total_bytes == $len
1926 0 0 unless defined $bytes
1928 0 0 if $total_bytes != $len and $self->_warnings_is_enabled
1939 0 0 unless defined $bytes
1941 0 0 if (defined $io) { }
0 0 elsif (length($data) + length($buff) > $max_in_memory) { }
1944 0 0 unless defined $bytes_out
1953 0 0 unless defined $bytes_out
1955 0 0 unless defined $bytes_out
1963 0 0 defined $file ? :
1970 0 0 if (defined $file) { }
1972 0 0 if ($mime_type eq $default_mime) { }
1974 0 0 unless ($mime)
1976 0 0 unless $self->_load_class("HTTP::Promise::MIME")
1982 0 0 unless defined $mime_type
1984 0 0 if ($self->ext_vary and $enc = $headers->content_encoding)
1986 0 0 unless $self->_load_class("HTTP::Promise::Stream")
1989 0 0 unless $enc_exts->is_empty
1993 0 0 if ($mtype and $mtype ne $default_mime) { }
0 0 elsif (defined $enc_ext) { }
2000 0 0 unless defined $new_ext
2001 0 0 if ($new_ext and $new_ext ne $ext)
2003 0 0 if defined $enc_ext
2021 0 0 if ($self->ext_vary and $enc = $headers->content_encoding)
2023 0 0 unless $self->_load_class("HTTP::Promise::Stream")
2027 0 0 unless ($enc_exts->is_empty)
2047 0 0 if ($type eq 'application/x-www-form-urlencoded') { }
2067 0 0 unless $self->_is_a($headers, "HTTP::Promise::Headers")
2069 0 0 unless $self->_is_a($ent, "HTTP::Promise::Entity")
2071 0 0 unless $self->_is_a($reader, "HTTP::Promise::IO")
2081 0 0 unless $self->_load_class("HTTP::Promise::MIME")
2084 0 0 unless defined $ext
2087 0 0 if ($self->ext_vary and $enc = $headers->content_encoding)
2089 0 0 unless $self->_load_class("HTTP::Promise::Stream")
2092 0 0 unless $enc_ext->is_empty
2123 0 0 unless defined $hdr
2124 0 0 unless length $hdr
2130 0 0 if ($len == 0)
2137 0 0 if $chunk_size > $len
2141 0 0 if ($ent->is_binary($buff)) { }
2143 0 0 if (-t STDIN) { }
2157 0 0 unless defined $bytes_out
2159 0 0 if ($bytes_out != $bytes)
2164 0 0 if $total_bytes == $len
2166 0 0 if $total_bytes < $len and $total_bytes + $chunk_size > $len
2168 0 0 unless defined $bytes
2171 0 0 unless defined $trash
2177 0 0 defined $enc && length $enc ? :