HTTP2/Frame/Push_promise.pm

filter: Statementstmt 33.3% 13 / 39 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 2 totaltotal 24.6% 17 / 69 CC 8 SCAR 38.0
CC
8
Cov
23%
decode
72.0
encode
2.0
BEGIN
1.0
CRAP 44.8
« HTTP2/HeaderCompression.pm ↑ Summary HTTP2/Stream.pm »
1 package Protocol::HTTP2::Frame::Push_promise;
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);
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 0 ▶sub decode {
Subroutine decode: not called CC=8 SCAR=42.8
Pod undocumented
8 0 my ( $con, $buf_ref, $buf_offset, $length ) = @_;
9 0 my ( $pad, $offset ) = ( 0, 0 );
10 0 my $frame_ref = $con->decode_context->{frame};
11  
12 # Protocol errors
13 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($frame_ref->{"stream"} == 0 or not $con->dec_setting(2)) 0 0 0
Condition0%0/3
$frame_ref->{"stream"} == 0 or not $con->dec_setting(2)
l!l&&r!l&&!r
000
MC/DC0%0/2
$frame_ref->{"stream"} == 0 or not $con->dec_setting(2)
$frame_ref->{"stream"} == 0 not $con->dec_setting(2)
Truth table0%0/3
A or not(B)
A= $frame_ref->{"stream"} == 0B= not $con->dec_setting(2)
ABresult
1X1
011
000
14 # PP frames MUST be associated with a stream
15 $frame_ref->{stream} == 0
16  
17 # PP frames MUST be allowed
18 || !$con->dec_setting(SETTINGS_ENABLE_PUSH)
19 )
20 {
21 0 $con->error(PROTOCOL_ERROR);
22 0 return undef;
23 }
24  
25 0 ▶ if ( $frame_ref->{flags} & PADDED ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($frame_ref->{"flags"} & 8) 0 0 0
26 0 $pad = unpack( 'C', substr( $$buf_ref, $buf_offset ) );
27 0 $offset += 1;
28 }
29  
30 0 my $promised_sid = unpack 'N', substr $$buf_ref, $buf_offset + $offset, 4;
31 0 $promised_sid &= 0x7FFF_FFFF;
32 0 $offset += 4;
33  
34 0 my $hblock_size = $length - $offset - $pad;
35 0 ▶ if ( $hblock_size < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hblock_size < 0) 0 0 0
36 0 tracer->error("Not enough space for header block\n");
37 0 $con->error(FRAME_SIZE_ERROR);
38 0 return undef;
39 }
40  
41 0 ▶ $con->new_peer_stream($promised_sid) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$con->new_peer_stream($promised_sid) or return undef 0 0 0
42 0 $con->stream_promised_sid( $frame_ref->{stream}, $promised_sid );
43  
44 $con->stream_header_block( $frame_ref->{stream},
45 0 substr( $$buf_ref, $buf_offset + $offset, $hblock_size ) );
46  
47 # PP header block complete
48 $con->stream_headers_done( $frame_ref->{stream} )
49 or return undef
50 0 ▶ if $frame_ref->{flags} & END_HEADERS;
Branch: 1 branch
BranchTrueFalseTotal
if $frame_ref->{"flags"} & 4 0 0 0
Condition0%0/5
$frame_ref->{'flags'} & 4 && ($con->stream_headers_done($frame_ref->{'stream'}) || (return undef))
!ll&&!rl&&r
000
$con->stream_headers_done($frame_ref->{"stream"}) or return undef
l!l
00
MC/DC0%0/2
$frame_ref->{'flags'} & 4 && ($con->stream_headers_done($frame_ref->{'stream'}) || (return undef))
$frame_ref->{'flags'} & 4 $con->stream_headers_done($frame_ref->{"stream"})
Truth table0%0/3
A && B
A= $frame_ref->{'flags'} & 4B= $con->stream_headers_done($frame_ref->{"stream"})
ABresult
0X0
100
111
51  
52 0 return $length;
53  
54 }
55  
56 0 ▶sub encode {
Subroutine encode: not called CC=1 SCAR=6.9
Pod undocumented
57 0 my ( $con, $flags_ref, $stream_id, $data_ref ) = @_;
58 0 my $promised_id = $data_ref->[0];
59 0 my $hblock_ref = $data_ref->[1];
60  
61 0 return pack( 'N', $promised_id ) . $$hblock_ref;
62 }
63  
64 13 1;
« HTTP2/HeaderCompression.pm ↑ Summary HTTP2/Stream.pm »