| 1 | package Protocol::HTTP2::Frame::Data; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 13 | ▶ | use Protocol::HTTP2::Constants qw(:flags :errors :settings :limits); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 13 | ▶ | use Protocol::HTTP2::Trace qw(tracer); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 49 | ▶ | sub decode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode: called CC=14 SCAR=32.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 49 | my ( $con, $buf_ref, $buf_offset, $length ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 49 | my ( $pad, $offset ) = ( 0, 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 10 | 49 | my $frame_ref = $con->decode_context->{frame}; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | # Protocol errors | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 49 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | # DATA frames MUST be associated with a stream | ||||||||||||||||||||||||||||||||||||||||||
| 15 | $frame_ref->{stream} == 0 | ||||||||||||||||||||||||||||||||||||||||||
| 16 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 17 | { | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | $con->error(PROTOCOL_ERROR); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 49 | ▶ | if ( $frame_ref->{flags} & PADDED ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | $pad = unpack( 'C', substr( $$buf_ref, $buf_offset ) ); | |||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | $offset += 1; | |||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 49 | my $dblock_size = $length - $offset - $pad; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 49 | ▶ | if ( $dblock_size < 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | tracer->error("Not enough space for data block\n"); | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $con->error(PROTOCOL_ERROR); | |||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 49 | my $fcw = $con->fcw_recv( -$length ); | |||||||||||||||||||||||||||||||||||||||||
| 35 | 49 | my $stream_fcw = $con->stream_fcw_recv( $frame_ref->{stream}, -$length ); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 49 | ▶ | if ( $fcw < 0 || $stream_fcw < 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$fcw < 0 or $stream_fcw < 0
MC/DC0%0/2
$fcw < 0 or $stream_fcw < 0
$fcw < 0
$stream_fcw < 0
Truth table33%1/3
A or B
A= $fcw < 0B= $stream_fcw < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | tracer->warning( | |||||||||||||||||||||||||||||||||||||||||
| 38 | "received data overflow flow control window: $fcw|$stream_fcw\n"); | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $con->stream_error( $frame_ref->{stream}, FLOW_CONTROL_ERROR ); | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | return $length; | |||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 49 | ▶ | $con->fcw_update() if $fcw < $con->dec_setting(SETTINGS_MAX_FRAME_SIZE); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | $con->stream_fcw_update( $frame_ref->{stream} ) | ||||||||||||||||||||||||||||||||||||||||||
| 44 | if $stream_fcw < $con->dec_setting(SETTINGS_MAX_FRAME_SIZE) | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 49 | ▶ | && !( $frame_ref->{flags} & END_STREAM ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$stream_fcw < $con->dec_setting(5) and not $frame_ref->{"flags"} & 1
MC/DC0%0/2
$stream_fcw < $con->dec_setting(5) and not $frame_ref->{"flags"} & 1
$stream_fcw < $con->dec_setting(5)
not $frame_ref->{"flags"} & 1
Truth table33%1/3
A and not(B)
A= $stream_fcw < $con->dec_setting(5)B= not $frame_ref->{"flags"} & 1
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 49 | ▶ | return $length unless $dblock_size; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 20 | my $data = substr $$buf_ref, $buf_offset + $offset, $dblock_size; | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | # Update stream data container | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 20 | $con->stream_data( $frame_ref->{stream}, $data ); | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | # Check length of data matched content-length in header | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 20 | ▶ | if ( $frame_ref->{flags} & END_STREAM ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 5 | my $slen = $con->stream_length( $frame_ref->{stream} ); | |||||||||||||||||||||||||||||||||||||||||
| 57 | 5 | ▶ | if ( defined $slen && defined $con->stream_data( $frame_ref->{stream} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $slen and defined $con->stream_data($frame_ref->{"stream"}) and $slen != length $con->stream_data($frame_ref->{"stream"})
defined $slen and defined $con->stream_data($frame_ref->{"stream"})
MC/DC0%0/3
defined $slen and defined $con->stream_data($frame_ref->{"stream"}) and $slen != length $con->stream_data($frame_ref->{"stream"})
defined $slen
defined $con->stream_data($frame_ref->{"stream"})
$slen != length $con->stream_data($frame_ref->{"stream"})
Truth table50%2/4
A and B and C
A= defined $slenB= defined $con->stream_data($frame_ref->{"stream"})C= $slen != length $con->stream_data($frame_ref->{"stream"})
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | && $slen != length $con->stream_data( $frame_ref->{stream} ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 59 | { | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | tracer->warning( | |||||||||||||||||||||||||||||||||||||||||
| 61 | "content-length header don't match data frames size\n"); | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $con->stream_error( $frame_ref->{stream}, PROTOCOL_ERROR ); | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 20 | return $length; | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 48 | ▶ | sub encode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 48 | my ( $con, $flags_ref, $stream_id, $data_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 48 | return $$data_ref; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||