HTTP2/Frame/Priority.pm

filter: Statementstmt 80.0% 28 / 35 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 75.5% 37 / 49 CC 4 SCAR 10.5
CC
4
Cov
76%
decode
5.2
BEGIN
1.0
BEGIN
1.0
CRAP 2.8
« HTTP2/Frame/Continuation.pm ↑ Summary HTTP2/Frame/Ping.pm »
1 package Protocol::HTTP2::Frame::Priority;
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);
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 1 ▶sub decode {
Subroutine decode: called CC=4 SCAR=16.4
Pod undocumented
8 1 my ( $con, $buf_ref, $buf_offset, $length ) = @_;
9 1 my $frame_ref = $con->decode_context->{frame};
10  
11 # Priority frames MUST be associated with a stream
12 1 ▶ if ( $frame_ref->{stream} == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($frame_ref->{"stream"} == 0) 0 1 1
13 0 $con->error(PROTOCOL_ERROR);
14 0 return undef;
15 }
16  
17 1 ▶ if ( $length != 5 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length != 5) 0 1 1
18 0 $con->error(FRAME_SIZE_ERROR);
19 0 return undef;
20 }
21  
22 1 my ( $stream_dep, $weight ) =
23 unpack( 'NC', substr( $$buf_ref, $buf_offset, 5 ) );
24 1 my $exclusive = $stream_dep >> 31;
25 1 $stream_dep &= 0x7FFF_FFFF;
26 1 $weight++;
27  
28 1 $con->stream_weight( $frame_ref->{stream}, $weight );
29 1 ▶ unless (
Branch: 1 branch
BranchTrueFalseTotal
unless ($con->stream_reprio($frame_ref->{"stream"}, $exclusive, $stream_dep)) 0 1 1
30 $con->stream_reprio( $frame_ref->{stream}, $exclusive, $stream_dep ) )
31 {
32 0 tracer->error("Malformed priority frame");
33 0 $con->error(PROTOCOL_ERROR);
34 0 return undef;
35 }
36  
37 1 return $length;
38 }
39  
40 1 ▶sub encode {
Subroutine encode: called CC=1 SCAR=0.0
Pod undocumented
41 1 my ( $con, $flags_ref, $stream, $data_ref ) = @_;
42 1 my $stream_dep = $data_ref->[0];
43 1 my $weight = $data_ref->[1] - 1;
44 1 pack( 'NC', $stream_dep, $weight );
45 }
46  
47 13 1;
« HTTP2/Frame/Continuation.pm ↑ Summary HTTP2/Frame/Ping.pm »