Branch Coverage

lib/HTTP/Promise/Parser.pm
Criterion Covered Total %
branch 144 280 51.4


line true false branch
97 0 35 unless $self->SUPER::init(@_)
99 0 35 unless defined $dir and length $dir
100 0 35 unless $dir->exists
101 0 35 unless $dir->is_dir
115 0 0 if ref $this and not $self->_is_scalar($this)
116 0 0 $self->_is_scalar($this) ? :
117 0 0 if ($$ref =~ /^$HTTP::Promise::Parser::REQUEST/) { }
133 0 0 if ref $this and not $self->_is_scalar($this)
134 0 0 $self->_is_scalar($this) ? :
135 0 0 if ($$ref =~ /^$HTTP::Promise::Parser::RESPONSE/) { }
152 0 2 unless defined $this
153 0 2 if ref $this and not $self->_is_scalar($this)
154 0 2 $self->_is_scalar($this) ? :
156 0 2 unless defined $$ref and length $$ref
158 1 1 if ($$ref =~ /^$HTTP::Promise::Parser::REQUEST/) { }
1 0 elsif ($$ref =~ /^$HTTP::Promise::Parser::RESPONSE/) { }
169 0 2 unless defined $def
184 0 0 if ($self->tmp_to_core) { }
194 0 0 unless $io->open(">", {"binmode", "raw", "autoflush", 1})
207 4 19 if ($self->_is_glob($this)) { }
17 2 elsif ($self->_is_scalar($this)) { }
213 0 17 unless $self->_load_class("Module::Generic::Scalar::IO")
229 0 1 if ref $_[0] and not overload::Method($_[0], "\"\"")
237 0 22 unless defined $fh
238 0 22 unless $self->_is_glob($fh)
241 2 20 if ($reader = $opts->{'reader'}) { }
243 0 2 unless $self->_is_a($reader, "HTTP::Promise::IO")
255 0 22 unless defined $buff
256 18 0 unless ($opts->{'request'} or $opts->{'response'})
259 2 16 if ($buff =~ /^($HTTP::Promise::Parser::HTTP_VERSION)[[:blank:]]+/) { }
3 13 elsif ($buff =~ /^(?:CONNECT|DELETE|GET|HEAD|OPTIONS|PATCH|POST|PUT|TRACE)[[:blank:]]+(\S+)[[:blank:]]+$HTTP::Promise::Parser::HTTP_VERSION/) { }
285 0 25 unless defined $n
286 7 18 if ($n == 0)
288 0 7 if (not length $buff) { }
299 9 9 if ($opts->{'request'} or $opts->{'response'}) { }
310 4 14 if (not defined $def) { }
313 0 4 if $self->error->code == 400 and length $buff > $max
315 3 1 if $self->error->code == 425
323 0 14 unless $self->_is_integer($def->{'length'})
324 0 14 if $def->{'length'} > length $buff
326 14 0 if length $buff
335 9 0 if ($opts->{'request'} || $opts->{'response'} and $def->{'protocol'})
338 7 2 if ($opts->{'request'}) { }
340 0 7 unless $self->_load_class("HTTP::Promise::Request")
350 0 2 unless $self->_load_class("HTTP::Promise::Response")
369 3 10 if ($type =~ m[^multipart/]i) { }
376 4 8 if (my $dispo = $_->headers->content_disposition)
379 0 4 unless defined $cd
380 4 0 if (my $name = $cd->name)
399 0 57 unless defined $str
403 0 57 unless (length $$str)
412 7 50 unless ($$str =~ /$HTTP::Promise::Parser::CRLF$HTTP::Promise::Parser::CRLF/)
419 9 41 if ($$str =~ /^($HTTP::Promise::Parser::HTTP_VERSION)[[:blank:]]+(?<code>\d{3})[[:blank:]]+(?<status>.*?)$HTTP::Promise::Parser::CRLF/cg) { }
9 32 elsif ($$str =~ /^(?<method>[A-Z]{3,12})[[:blank:]]+(?<uri>\S+)[[:blank:]]+($HTTP::Promise::Parser::HTTP_VERSION)$HTTP::Promise::Parser::CRLF/cg) { }
2 30 elsif ($$str =~ /^(GET)[[:blank:]]+(\S+)[[:blank:]]*$HTTP::Promise::Parser::CRLF/cg) { }
5 25 elsif ($$str =~ m[^(?:[A-Z]+/\d+\.\d+|[A-Z]+[[:blank:]\h]+(?!\:))]) { }
442 0 2 if $$str =~ /^$HTTP::Promise::Parser::HEADER/
449 2 3 $$str =~ m[^[A-Z]+\/\d+\.\d+] ? :
453 4 39 if (pos $$str == 0 and not $$str =~ /^$HTTP::Promise::Parser::HEADER/)
468 0 59 if $opts->{'convert_dash'}
473 2 37 unless ($$str =~ /\G$HTTP::Promise::Parser::CRLF/cg)
475 1 1 $def->{'code'} ? :
496 0 2 unless (exists $opts->{'request'} || exists $opts->{'response'} and length $opts->{'request'} || length $opts->{'response'})
510 8 2 if ($opts->{'request'}) { }
2 0 elsif ($opts->{'response'}) { }
516 0 8 if (index($$str, "HTTP/2") != -1)
518 0 0 if ($$str =~ s[^((?:\S+)[[:blank:]\h]+(?:\S+)[[:blank:]\h]+HTTP/)(2(?:\.\d)?)][$11.1])
527 0 2 if (index($$str, "HTTP/2") != -1)
529 0 0 if ($$str =~ s[^(HTTP/)(2(?:\.\d)?)][$11.1])
537 0 10 if ($@)
542 0 10 if ($len == -1) { }
0 10 elsif ($len == -2 and $max_headers_size > 0 and length $$str > $max_headers_size) { }
0 10 elsif ($len == -2) { }
587 0 10 if defined $bkp_version
599 0 39 if $opts->{'convert_dash'}
603 8 2 if ($opts->{'request'}) { }
2 0 elsif ($opts->{'response'}) { }
606 8 0 if exists $r->{'_request_uri'} and length $r->{'_request_uri'}
641 0 4 unless defined $trash
642 0 4 unless length $trash
645 4 0 if (length $delim)
649 2 2 if length $preamble
658 0 14 unless defined $hdr
659 0 14 unless length $hdr
661 10 4 if (length $hdr and not $hdr =~ /^$HTTP::Promise::Parser::CRLF$/) { }
674 4 0 if $hdr =~ /^$HTTP::Promise::Parser::CRLF$/
679 1 13 if (defined $mime_type and $mime_type eq 'multipart/form-data') { }
690 1 0 if (length $delim)
694 1 0 if length $epilogue
699 2 0 if (my $dispo = $_->headers->content_disposition)
702 0 2 unless defined $cd
703 2 0 if (my $name = $cd->name)
724 4 10 if $last =~ /\-\-$boundary\-\-$HTTP::Promise::Parser::CRLF$/
741 0 0 unless $io->close
770 0 0 unless $$str =~ s/^$HTTP::Promise::Parser::REQUEST//
788 1 9 unless $$str =~ s/^$HTTP::Promise::Parser::CRLF//
789 1 8 if ($req->{'version'} < "version"->parse("1.0"))
791 0 1 unless $$str eq ""
822 0 0 unless $$str =~ s/^$HTTP::Promise::Parser::RESPONSE//
842 0 8 unless $$str =~ s/^$HTTP::Promise::Parser::CRLF//
875 0 0 unless $self->_load_class("HTTP::Promise::MIME")
878 0 0 unless defined $ext
885 1 22 if (defined $len and not defined $read_until) { }
888 0 1 if (not $len) { }
0 1 elsif ($len > $max_in_memory) { }
896 0 0 if ($type eq "application/x-www-form-urlencoded" and $self->decode_body)
906 0 0 if $chunk_size > $len
909 0 0 unless $io->print($buff)
911 0 0 if $total_bytes + $chunk_size > $len
913 0 0 if $total_bytes == $len
916 0 0 unless defined $bytes
921 0 1 unless defined $bytes
925 0 1 if $total_bytes != $len and warnings::enabled(ref $self)
935 13 12 if (defined $read_until) { }
943 0 25 unless defined $bytes
945 0 25 if (defined $io) { }
0 25 elsif (length($data) + length($buff) > $max_in_memory) { }
947 0 0 unless $io->print($buff)
952 0 0 if ($type eq "application/x-www-form-urlencoded" and $self->decode_body)
960 0 0 unless $io->print($data)
968 10 15 if $bytes < 0
970 0 22 defined $file ? :
978 0 23 if (defined $file) { }
980 0 0 if (defined $file and $mime_type eq $default_mime)
982 0 0 unless ($mime)
984 0 0 unless $self->_load_class("HTTP::Promise::MIME")
990 0 0 unless defined $mime_type
991 0 0 if ($mtype and $mtype ne $default_mime)
998 0 0 unless defined $new_ext
999 0 0 if ($new_ext and $new_ext ne $ext)
1016 1 22 if (defined $type and $type eq 'application/x-www-form-urlencoded') { }
1029 4 0 if ($enc and $body->length and $self->decode_body($enc))
1031 0 4 unless $ent->decode_body($enc)
1041 0 10 unless defined $str and length $str
1042 0 10 unless $str =~ /^$HTTP::Promise::Parser::HTTP_VERSION$/
1048 0 10 want('LIST') ? :
1059 16 84 if (not ref $str) { }
0 84 elsif (not $self->_is_scalar($str)) { }
1074 0 5 unless defined $ref
1075 0 5 unless $self->_is_scalar($ref)