Branch Coverage

blib/lib/Net/Inspect/L7/HTTP.pm
Criterion Covered Total %
branch 256 466 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'))
359 0 17 if (@warn and %Net::Inspect::L7::HTTP::TRACE)
363 1 16 if ($err)
370 4 12 if ($hdr{'chunked'}) { }
3 9 elsif ($hdr{'content_length'}) { }
381 0 0 if %Net::Inspect::L7::HTTP::TRACE and $hdr{'junk'}
384 16 0 if $obj
386 9 7 if ($body_done)
387 0 9 if $Net::Inspect::L7::HTTP::DEBUG
389 2 7 if ($hdr{'method'} eq 'CONNECT' or $hdr{'upgrade'}) { }
395 7 0 if $obj
416 0 3 if $Net::Inspect::L7::HTTP::DEBUG
422 27 16 if ($data ne '' and not $rq->{'state'} & 2)
424 10 17 if (my $want = $rq->{'rqclen'}) { }
426 8 2 if ($l >= $want) { }
428 0 8 if $Net::Inspect::L7::HTTP::DEBUG
433 1 7 if (not $rq->{'rqchunked'}) { }
434 0 1 if $Net::Inspect::L7::HTTP::DEBUG
436 1 0 if $obj
438 7 0 if $obj
443 0 2 if $Net::Inspect::L7::HTTP::DEBUG
448 2 0 if $obj
454 7 10 if ($rq->{'rqchunked'} == 2)
455 0 7 if $Net::Inspect::L7::HTTP::DEBUG
456 7 0 if ($data =~ /\A\r?\n/g) { }
0 0 elsif (length $data >= 2) { }
462 0 7 if $Net::Inspect::L7::HTTP::DEBUG
474 17 0 if ($rq->{'rqchunked'} == 1)
475 0 17 if $Net::Inspect::L7::HTTP::DEBUG
476 11 6 if ($data =~ /\A([\da-fA-F]+)[ \t]*(?:;.*)?\r?\n/g) { }
0 6 elsif ($data =~ /\n/ or length $data > 8192) { }
483 7 4 if $rq->{'rqclen'}
485 11 0 if $obj
486 0 11 if $Net::Inspect::L7::HTTP::DEBUG
488 4 7 unless ($rq->{'rqclen'})
491 4 0 if $obj
504 4 7 if ($rq->{'rqchunked'} == 3)
505 0 4 if $Net::Inspect::L7::HTTP::DEBUG
506 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) { }
510 0 4 if $Net::Inspect::L7::HTTP::DEBUG
514 4 0 if $obj
523 0 0 if %Net::Inspect::L7::HTTP::TRACE
529 0 0 if $Net::Inspect::L7::HTTP::DEBUG
548 2 35 if (ref $data)
550 0 2 if $data->[0] ne 'gap'
553 0 2 if $self->{'error'}
556 0 2 unless @$rqs
558 0 2 if $rq->{'state'} & 4
560 0 2 if $self->{'gap_upto'}[1] >= 0 and $self->{'gap_upto'}[1] < $self->{'offset'}[1] + $len
562 2 0 if defined $rq->{'rpclen'}
566 0 2 if ($self->{'upgrade'}) { }
0 2 elsif ($rq->{'rpclen'} or not defined $rq->{'rpclen'} or $rq->{'rpchunked'}) { }
571 0 0 if $obj
574 0 2 if $Net::Inspect::L7::HTTP::DEBUG
576 2 0 if $obj
584 0 60 if $self->{'error'}
585 20 40 if $data eq '' and not $eof
587 5 35 if ($self->{'upgrade'})
593 2 33 if ($data eq '')
594 0 2 if $Net::Inspect::L7::HTTP::DEBUG
598 2 0 if (@$rqs and $rqs->[-1]{'state'} & 16) { }
0 0 elsif (@$rqs) { }
601 0 2 if $Net::Inspect::L7::HTTP::DEBUG
602 2 0 if $rq->{'obj'}
607 0 0 if $Net::Inspect::L7::HTTP::DEBUG
608 0 0 if (($rq->{'state'} & 8) == 0) { }
609 0 0 if ($data eq '' and $self->{'lastreqid'} > 1) { }
0 0 elsif ($data eq '') { }
620 0 0 if %Net::Inspect::L7::HTTP::TRACE
627 0 0 if %Net::Inspect::L7::HTTP::TRACE
635 0 33 unless (@$rqs)
636 0 0 if ($data =~ s/\A([\r\n]+)//)
652 15 18 unless ($rq->{'state'} & 8)
653 0 15 if $Net::Inspect::L7::HTTP::DEBUG
656 0 15 if ($data =~ s/\A([\r\n]+)//)
661 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) { }
669 0 14 if ($err and my $sub = $obj->can('fix_rsphdr'))
674 1 13 if $err
675 0 13 if $Net::Inspect::L7::HTTP::DEBUG
677 0 0 if %Net::Inspect::L7::HTTP::TRACE and $hdr{'junk'}
680 1 12 if ($hdr{'preliminary'})
682 1 0 if $obj
688 2 10 if ($hdr{'upgrade'}) { }
0 10 elsif ($rq->{'request'}{'upgrade'}) { }
698 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') { }
705 0 1 unless ($self->{'upgrade'} = eval { do { &$sub($obj, $self, $rq->{'request'}, \%hdr) } })
715 0 0 unless ($self->{'upgrade'} = eval { do { &$sub($obj, $self, $rq->{'request'}, \%hdr, $hdr{'upgrade'}) } })
740 0 0 if $obj
744 2 8 if ($hdr{'chunked'}) { }
6 2 elsif (defined $hdr{'content_length'}) { }
747 3 3 if ($rq->{'rpclen'} = $hdr{'content_length'}) { }
760 12 0 if $obj
762 3 9 if ($body_done)
763 0 3 if $Net::Inspect::L7::HTTP::DEBUG
765 3 0 if $obj
795 0 1 if $Net::Inspect::L7::HTTP::DEBUG
801 18 0 if ($data ne '')
803 0 18 if $Net::Inspect::L7::HTTP::DEBUG
806 6 12 if (my $want = $rq->{'rpclen'}) { }
2 10 elsif ($rq->{'state'} & 16) { }
0 10 elsif (not $rq->{'rpchunked'}) { }
810 5 1 if ($l >= $want) { }
811 0 5 if $Net::Inspect::L7::HTTP::DEBUG
817 1 4 if (not $rq->{'rpchunked'}) { }
820 0 1 if $Net::Inspect::L7::HTTP::DEBUG
821 1 0 if $obj
823 4 0 if $obj
828 0 1 if $Net::Inspect::L7::HTTP::DEBUG
833 1 0 if $obj
838 0 2 if $Net::Inspect::L7::HTTP::DEBUG
841 0 2 if ($eof)
844 0 0 if $Net::Inspect::L7::HTTP::DEBUG
846 2 0 if $obj
856 4 6 if ($rq->{'rpchunked'} == 2)
857 0 4 if $Net::Inspect::L7::HTTP::DEBUG
858 4 0 if ($data =~ /\A\r?\n/g) { }
0 0 elsif (length $data >= 2) { }
864 0 4 if $Net::Inspect::L7::HTTP::DEBUG
876 10 0 if ($rq->{'rpchunked'} == 1)
877 0 10 if $Net::Inspect::L7::HTTP::DEBUG
878 6 4 if ($data =~ /\A([\da-fA-F]+)[ \t]*(?:;.*)?\r?\n/g) { }
0 4 elsif ($data =~ /\n/ or length $data > 8192) { }
884 4 2 if $rq->{'rpclen'}
886 6 0 if $obj
887 0 6 if $Net::Inspect::L7::HTTP::DEBUG
889 2 4 unless ($rq->{'rpclen'})
892 2 0 if $obj
905 2 4 if ($rq->{'rpchunked'} == 3)
906 0 2 if $Net::Inspect::L7::HTTP::DEBUG
907 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]) { }
911 0 2 if $Net::Inspect::L7::HTTP::DEBUG
915 2 0 if $obj
924 0 0 if $Net::Inspect::L7::HTTP::DEBUG
937 13 18 unless defined $hdr
941 24 0 if ($3 eq '') { }
952 18 18 if (pos $hdr // 0 != length $hdr)
955 0 18 if $hdr =~ s/\A([^\n]*)\n//
963 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
989 0 17 if $bad ne ''
992 1 11 if ($version >= 1.1 and $kv{'expect'})
995 1 0 if /\b(100-continue)\b/i
1001 4 13 if ($version >= 1.1 and grep {/(?:^|[ \t,])chunked(?:$|[ \t,;])/i;} @{[] unless $kv{'transfer-encoding'};}) { }
5 8 elsif (my $cl = $kv{'content-length'}) { }
1003 8 4 unless $kv{'transfer-encoding'}
1009 0 5 if @$cl > 1 and do { my %x; @x{@$cl} = (); keys %x } > 1
1010 1 4 unless $cl->[0] =~ /^(\d+)$/
1015 8 8 if ($METHODS_WITHOUT_RQBODY{$method}) { }
8 0 elsif ($METHODS_WITH_RQBODY{$method}) { }
0 0 elsif (not $hdr->{'chunked'}) { }
1018 0 8 if $hdr->{'content_length'} or $hdr->{'chunked'}
1024 0 0 unless $hdr->{'chunked'} or defined $hdr->{'content_length'} or $external_length
1032 1 10 if ($version >= 1.1 and $kv{'upgrade'} and my(%upgrade) = map({lc $_, 1;} map({/($token)/g;} @{$kv{'upgrade'};})))
1042 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
1068 0 14 if $bad ne ''
1070 2 12 if ($code <= 199)
1074 2 0 if ($code == 100 and $request->{'expect'}{'100-continue'} or $code == 102 or $code == 101) { }
1078 0 0 if $warn
1085 1 13 if ($code == 101)
1087 1 0 if ($request->{'upgrade'} and grep {/\bUPGRADE\b/i;} @{[] unless $kv{'connection'};})
1088 0 1 unless $kv{'connection'}
1089 0 1 unless $kv{'upgrade'}
1094 1 0 if (keys %proto == 1) { }
1104 1 0 if ($request->{'method'} eq 'CONNECT' and $code >= 200 and $code < 300)
1113 2 11 if ($version >= 1.1 and grep {/(?:^|[ \t,])chunked(?:$|[ \t,;])/i;} @{[] unless $kv{'transfer-encoding'};}) { }
5 6 elsif (my $cl = $kv{'content-length'}) { }
1115 7 2 unless $kv{'transfer-encoding'}
1121 0 5 if @$cl > 1 and do { my %x; @x{@$cl} = (); keys %x } > 1
1122 1 4 unless $cl->[0] =~ /^(\d+)$/
1127 4 8 if ($CODE_WITHOUT_RPBODY{$code} or $METHODS_WITHOUT_RPBODY{$request->{'method'}})
1147 0 0 @_ ? :
1149 0 0 $_->{'obj'} ? :
0 0 wantarray ? :
1155 0 0 if %Net::Inspect::L7::HTTP::TRACE
1167 0 0 unless $Net::Inspect::L7::HTTP::DEBUG
1176 0 0 unless $Net::Inspect::L7::HTTP::DEBUG or defined wantarray
1186 0 0 if defined wantarray