Branch Coverage

blib/lib/Net/Inspect/L7/HTTP.pm
Criterion Covered Total %
branch 255 464 54.9


line true false branch
86 0 0 if ($dir == 0) { }
90 0 0 if ($buf =~ m[ \A[\r\n]* # initial junk [A-Z]{2,20}[\040\t]{1,3} # method \S+[\040\t]{1,3} # path/URI HTTP/1\.[01][\040\t]{0,3} # version \r?\n # (CR)LF (?:$xtoken:.*\r?\n(?:[\t\040].*\r?\n)* )* # field:..+cont \r?\n # empty line ]xi) { }
0 0 elsif ($buf =~ /[^\n]\r?\n\r?\n/ or length $buf > 65536) { }
105 0 0 if $n <= 0
151 0 0 ref $data ? :
0 92 if $Net::Inspect::L7::HTTP::DEBUG
155 55 37 $dir == 0 ? :
164 0 0 wantarray ? :
174 21 31 ($off -= $self->{'offset'}[$_]) > 0 ? :
6 52 $off == -1 ? :
177 29 0 wantarray ? :
183 2 0 defined $diff ? :
194 14 16 $off > $self->{'offset'}[$_] ? :
2 30 $off == -1 ? :
197 16 0 wantarray ? :
213 7 48 if (ref $data)
215 0 7 if $data->[0] ne 'gap'
218 0 7 if $self->{'error'}
222 0 7 if not @$rqs or $rqs->[0]{'state'} & 2 and not $self->{'upgrade'}
223 0 7 if $rqs->[0]{'state'} & 4
225 0 7 if $self->{'gap_upto'}[0] >= 0 and $self->{'gap_upto'}[0] < $self->{'offset'}[0] + $len
227 2 5 if (defined $rqs->[0]{'rqclen'})
229 2 0 unless ($rqs->[0]{'rqclen'} or $rqs->[0]{'rqchunked'})
236 5 2 if ($self->{'upgrade'}) { }
2 0 elsif ($obj) { }
250 0 85 if ($self->{'error'})
251 0 0 if $Net::Inspect::L7::HTTP::DEBUG
255 10 75 if ($self->{'upgrade'})
261 0 75 if (@$rqs and $rqs->[0]{'state'} & 4)
263 0 0 if $Net::Inspect::L7::HTTP::DEBUG
267 0 75 if (!@$rqs || $rqs->[0]{'state'} & 2 and $data =~ /\A[\r\n]+/g)
276 0 0 if %Net::Inspect::L7::HTTP::TRACE
279 28 47 if ($data eq '')
280 0 28 if $Net::Inspect::L7::HTTP::DEBUG
281 28 0 unless $eof
285 0 0 if (@$rqs and not $rqs->[0]{'state'} & 2)
287 0 0 if %Net::Inspect::L7::HTTP::TRACE
298 17 30 if (not @$rqs or $rqs->[0]{'state'} & 2)
322 0 17 if ($Net::Inspect::L7::HTTP::DEBUG)
336 20 27 unless ($rq->{'state'} & 1)
340 0 20 if ($data =~ s/\A([\r\n]+)//)
344 0 20 if $Net::Inspect::L7::HTTP::DEBUG
345 17 3 if ($data =~ s/\A(\A.*?\n\r?\n)//s) { }
0 3 elsif ($data =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/) { }
0 3 elsif (length $data > $self->{'hdr_maxsz'}[0]) { }
0 3 elsif ($eof) { }
346 0 17 if $Net::Inspect::L7::HTTP::DEBUG
355 0 17 if ($err and my $sub = $obj->can('fix_reqhdr'))
360 1 16 if ($err)
367 4 12 if ($hdr{'chunked'}) { }
3 9 elsif ($hdr{'content_length'}) { }
378 0 0 if %Net::Inspect::L7::HTTP::TRACE and $hdr{'junk'}
381 16 0 if $obj
383 9 7 if ($body_done)
384 0 9 if $Net::Inspect::L7::HTTP::DEBUG
386 2 7 if ($hdr{'method'} eq 'CONNECT' or $hdr{'upgrade'}) { }
392 7 0 if $obj
413 0 3 if $Net::Inspect::L7::HTTP::DEBUG
419 27 16 if ($data ne '' and not $rq->{'state'} & 2)
421 10 17 if (my $want = $rq->{'rqclen'}) { }
423 8 2 if ($l >= $want) { }
425 0 8 if $Net::Inspect::L7::HTTP::DEBUG
430 1 7 if (not $rq->{'rqchunked'}) { }
431 0 1 if $Net::Inspect::L7::HTTP::DEBUG
433 1 0 if $obj
435 7 0 if $obj
440 0 2 if $Net::Inspect::L7::HTTP::DEBUG
445 2 0 if $obj
451 7 10 if ($rq->{'rqchunked'} == 2)
452 0 7 if $Net::Inspect::L7::HTTP::DEBUG
453 7 0 if ($data =~ /\A\r?\n/g) { }
0 0 elsif (length $data >= 2) { }
459 0 7 if $Net::Inspect::L7::HTTP::DEBUG
471 17 0 if ($rq->{'rqchunked'} == 1)
472 0 17 if $Net::Inspect::L7::HTTP::DEBUG
473 11 6 if ($data =~ /\A([\da-fA-F]+)[ \t]*(?:;.*)?\r?\n/g) { }
0 6 elsif ($data =~ /\n/ or length $data > 8192) { }
480 7 4 if $rq->{'rqclen'}
482 11 0 if $obj
483 0 11 if $Net::Inspect::L7::HTTP::DEBUG
485 4 7 unless ($rq->{'rqclen'})
488 4 0 if $obj
501 4 7 if ($rq->{'rqchunked'} == 3)
502 0 4 if $Net::Inspect::L7::HTTP::DEBUG
503 4 0 if ($data =~ /\A (?:\w[\w\-]*:.*\r?\n(?:[\t\040].*\r?\n)* )* # field:..+cont \r?\n /gx) { }
0 0 elsif ($data =~ /\n\r?\n/ or length $data > $self->{'hdr_maxsz'}[2]) { }
0 0 elsif ($eof) { }
507 0 4 if $Net::Inspect::L7::HTTP::DEBUG
511 4 0 if $obj
520 0 0 if %Net::Inspect::L7::HTTP::TRACE
526 0 0 if $Net::Inspect::L7::HTTP::DEBUG
545 2 35 if (ref $data)
547 0 2 if $data->[0] ne 'gap'
550 0 2 if $self->{'error'}
553 0 2 unless @$rqs
555 0 2 if $rq->{'state'} & 4
557 0 2 if $self->{'gap_upto'}[1] >= 0 and $self->{'gap_upto'}[1] < $self->{'offset'}[1] + $len
559 2 0 if defined $rq->{'rpclen'}
563 0 2 if ($self->{'upgrade'}) { }
0 2 elsif ($rq->{'rpclen'} or not defined $rq->{'rpclen'} or $rq->{'rpchunked'}) { }
568 0 0 if $obj
571 0 2 if $Net::Inspect::L7::HTTP::DEBUG
573 2 0 if $obj
581 0 60 if $self->{'error'}
582 20 40 if $data eq '' and not $eof
584 5 35 if ($self->{'upgrade'})
590 2 33 if ($data eq '')
591 0 2 if $Net::Inspect::L7::HTTP::DEBUG
595 2 0 if (@$rqs and $rqs->[-1]{'state'} & 16) { }
0 0 elsif (@$rqs) { }
598 0 2 if $Net::Inspect::L7::HTTP::DEBUG
599 2 0 if $rq->{'obj'}
604 0 0 if $Net::Inspect::L7::HTTP::DEBUG
605 0 0 if (($rq->{'state'} & 8) == 0) { }
606 0 0 if ($data eq '' and $self->{'lastreqid'} > 1) { }
0 0 elsif ($data eq '') { }
617 0 0 if %Net::Inspect::L7::HTTP::TRACE
624 0 0 if %Net::Inspect::L7::HTTP::TRACE
632 0 33 unless (@$rqs)
633 0 0 if ($data =~ s/\A([\r\n]+)//)
649 15 18 unless ($rq->{'state'} & 8)
650 0 15 if $Net::Inspect::L7::HTTP::DEBUG
653 0 15 if ($data =~ s/\A([\r\n]+)//)
658 14 1 if ($data =~ s/\A(.*?\n\r?\n)//s) { }
0 1 elsif ($data =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/) { }
0 1 elsif ($data =~ /[^\n]\r?\n\r?\n/g) { }
0 1 elsif (length $data > $self->{'hdr_maxsz'}[1]) { }
0 1 elsif ($eof) { }
666 0 14 if ($err and my $sub = $obj->can('fix_rsphdr'))
671 1 13 if $err
672 0 13 if $Net::Inspect::L7::HTTP::DEBUG
674 0 0 if %Net::Inspect::L7::HTTP::TRACE and $hdr{'junk'}
677 1 12 if ($hdr{'preliminary'})
679 1 0 if $obj
685 2 10 if ($hdr{'upgrade'}) { }
0 10 elsif ($rq->{'request'}{'upgrade'}) { }
695 0 2 if (not $obj) { }
1 1 elsif (my $sub = $obj->can('upgrade_' . $hdr{'upgrade'})) { }
0 1 elsif ($sub = $obj->can('upgrade_ANY')) { }
1 0 elsif ($hdr{'upgrade'} eq 'CONNECT') { }
702 0 1 unless ($self->{'upgrade'} = eval { do { &$sub($obj, $self, $rq->{'request'}, \%hdr) } })
712 0 0 unless ($self->{'upgrade'} = eval { do { &$sub($obj, $self, $rq->{'request'}, \%hdr, $hdr{'upgrade'}) } })
737 0 0 if $obj
741 2 8 if ($hdr{'chunked'}) { }
6 2 elsif (defined $hdr{'content_length'}) { }
744 3 3 if ($rq->{'rpclen'} = $hdr{'content_length'}) { }
757 12 0 if $obj
759 3 9 if ($body_done)
760 0 3 if $Net::Inspect::L7::HTTP::DEBUG
762 3 0 if $obj
792 0 1 if $Net::Inspect::L7::HTTP::DEBUG
798 18 0 if ($data ne '')
800 0 18 if $Net::Inspect::L7::HTTP::DEBUG
803 6 12 if (my $want = $rq->{'rpclen'}) { }
2 10 elsif ($rq->{'state'} & 16) { }
0 10 elsif (not $rq->{'rpchunked'}) { }
807 5 1 if ($l >= $want) { }
808 0 5 if $Net::Inspect::L7::HTTP::DEBUG
814 1 4 if (not $rq->{'rpchunked'}) { }
817 0 1 if $Net::Inspect::L7::HTTP::DEBUG
818 1 0 if $obj
820 4 0 if $obj
825 0 1 if $Net::Inspect::L7::HTTP::DEBUG
830 1 0 if $obj
835 0 2 if $Net::Inspect::L7::HTTP::DEBUG
838 0 2 if ($eof)
841 0 0 if $Net::Inspect::L7::HTTP::DEBUG
843 2 0 if $obj
853 4 6 if ($rq->{'rpchunked'} == 2)
854 0 4 if $Net::Inspect::L7::HTTP::DEBUG
855 4 0 if ($data =~ /\A\r?\n/g) { }
0 0 elsif (length $data >= 2) { }
861 0 4 if $Net::Inspect::L7::HTTP::DEBUG
873 10 0 if ($rq->{'rpchunked'} == 1)
874 0 10 if $Net::Inspect::L7::HTTP::DEBUG
875 6 4 if ($data =~ /\A([\da-fA-F]+)[ \t]*(?:;.*)?\r?\n/g) { }
0 4 elsif ($data =~ /\n/ or length $data > 8192) { }
881 4 2 if $rq->{'rpclen'}
883 6 0 if $obj
884 0 6 if $Net::Inspect::L7::HTTP::DEBUG
886 2 4 unless ($rq->{'rpclen'})
889 2 0 if $obj
902 2 4 if ($rq->{'rpchunked'} == 3)
903 0 2 if $Net::Inspect::L7::HTTP::DEBUG
904 2 0 if ($data =~ /\A (?:\w[\w\-]*:.*\r?\n(?:[\t\040].*\r?\n)* )* # field:..+cont \r?\n /gx) { }
0 0 elsif ($data =~ /\n\r?\n/ or length $data > $self->{'hdr_maxsz'}[2]) { }
908 0 2 if $Net::Inspect::L7::HTTP::DEBUG
912 2 0 if $obj
921 0 0 if $Net::Inspect::L7::HTTP::DEBUG
934 13 18 unless defined $hdr
938 24 0 if ($3 eq '') { }
949 18 18 if (pos $hdr // 0 != length $hdr)
952 0 18 if $hdr =~ s/\A([^\n]*)\n//
960 0 17 unless $data =~ m[\A ([A-Z]{2,20})[\040\t]+ # $1: method (\S+)[\040\t]+ # $2: path/URI HTTP/(1\.[01])[\40\t]* # $3: version \r?\n # (CR)LF ([^\r\n].*?\n)? # $4: fields \r?\n # final (CR)LF \Z]sx
986 0 17 if $bad ne ''
989 1 11 if ($version >= 1.1 and $kv{'expect'})
992 1 0 if /\b(100-continue)\b/i
998 4 13 if ($version >= 1.1 and grep {/(?:^|[ \t,])chunked(?:$|[ \t,;])/i;} @{[] unless $kv{'transfer-encoding'};}) { }
5 8 elsif (my $cl = $kv{'content-length'}) { }
1000 8 4 unless $kv{'transfer-encoding'}
1006 0 5 if @$cl > 1 and do { my %x; @x{@$cl} = (); keys %x } > 1
1007 1 4 unless $cl->[0] =~ /^(\d+)$/
1012 8 8 if ($METHODS_WITHOUT_RQBODY{$method}) { }
8 0 elsif ($METHODS_WITH_RQBODY{$method}) { }
0 0 elsif (not $hdr->{'chunked'}) { }
1015 0 8 if $hdr->{'content_length'} or $hdr->{'chunked'}
1021 0 0 unless $hdr->{'chunked'} or defined $hdr->{'content_length'} or $external_length
1029 1 10 if ($version >= 1.1 and $kv{'upgrade'} and my(%upgrade) = map({lc $_, 1;} map({/($token)/g;} @{$kv{'upgrade'};})))
1039 0 14 unless $data =~ m[\A HTTP/(1\.[01])[\040\t]+ # $1: version (\d\d\d) # $2: code (?:[\040\t]+([^\r\n]*))? # $3: reason \r?\n ([^\r\n].*?\n)? # $4: fields \r?\n # empty line \Z]sx
1065 0 14 if $bad ne ''
1067 2 12 if ($code <= 199)
1071 2 0 if ($code == 100 and $request->{'expect'}{'100-continue'} or $code == 102 or $code == 101) { }
1075 0 0 if $warn
1082 1 13 if ($code == 101)
1084 1 0 if ($request->{'upgrade'} and grep {/\bUPGRADE\b/i;} @{[] unless $kv{'connection'};})
1085 0 1 unless $kv{'connection'}
1086 0 1 unless $kv{'upgrade'}
1091 1 0 if (keys %proto == 1) { }
1101 1 0 if ($request->{'method'} eq 'CONNECT' and $code >= 200 and $code < 300)
1110 2 11 if ($version >= 1.1 and grep {/(?:^|[ \t,])chunked(?:$|[ \t,;])/i;} @{[] unless $kv{'transfer-encoding'};}) { }
5 6 elsif (my $cl = $kv{'content-length'}) { }
1112 7 2 unless $kv{'transfer-encoding'}
1118 0 5 if @$cl > 1 and do { my %x; @x{@$cl} = (); keys %x } > 1
1119 1 4 unless $cl->[0] =~ /^(\d+)$/
1124 4 8 if ($CODE_WITHOUT_RPBODY{$code} or $METHODS_WITHOUT_RPBODY{$request->{'method'}})
1144 0 0 @_ ? :
1146 0 0 $_->{'obj'} ? :
0 0 wantarray ? :
1152 0 0 if %Net::Inspect::L7::HTTP::TRACE
1164 0 0 unless $Net::Inspect::L7::HTTP::DEBUG
1173 0 0 unless $Net::Inspect::L7::HTTP::DEBUG or defined wantarray
1183 0 0 if defined wantarray