HTTP2/Frame/Goaway.pm

filter: Statementstmt 93.3% 28 / 30 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 84.0% 37 / 44 CC 4 SCAR 6.7
CC
4
Cov
86%
decode
3.2
encode
2.0
BEGIN
1.0
CRAP 1.9
« HTTP2/Constants.pm ↑ Summary HTTP2/Trace.pm »
1 package Protocol::HTTP2::Frame::Goaway;
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(const_name :flags :errors);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use Protocol::HTTP2::Trace qw(tracer bin2hex);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 9 ▶sub decode {
Subroutine decode: called CC=3 SCAR=11.5
Pod undocumented
8 9 my ( $con, $buf_ref, $buf_offset, $length ) = @_;
9 9 my $frame_ref = $con->decode_context->{frame};
10  
11 9 ▶ if ( $frame_ref->{stream} != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($frame_ref->{"stream"} != 0) 0 9 9
12 0 $con->error(PROTOCOL_ERROR);
13 0 return undef;
14 }
15  
16 9 my ( $last_stream_id, $error_code ) =
17 unpack( 'N2', substr( $$buf_ref, $buf_offset, 8 ) );
18  
19 9 $last_stream_id &= 0x7FFF_FFFF;
20  
21 9 tracer->debug( "GOAWAY with error code "
22 . const_name( 'errors', $error_code )
23 . " last stream is $last_stream_id\n" );
24  
25 9 ▶ tracer->debug( "additional debug data: "
Branch: 1 branch
BranchTrueFalseTotal
if $length - 8 > 0 0 9 9
26 . bin2hex( substr( $$buf_ref, $buf_offset + 8 ) )
27 . "\n" )
28 if $length - 8 > 0;
29  
30 9 $con->goaway(1);
31  
32 9 return $length;
33 }
34  
35 12 ▶sub encode {
Subroutine encode: called CC=2 SCAR=7.0
Pod undocumented
36 12 my ( $con, $flags_ref, $stream, $data ) = @_;
37  
38 12 $con->goaway(1);
39  
40 12 my $payload = pack( 'N2', @$data );
41 12 tracer->debug( "\tGOAWAY: last stream = $data->[0], error = "
42 . const_name( "errors", $data->[1] )
43 . "\n" );
44 12 ▶ $payload .= $data->[2] if @$data > 2;
Branch: 1 branch
BranchTrueFalseTotal
if @$data > 2 0 12 12
45 12 return $payload;
46 }
47  
48 13 1;
« HTTP2/Constants.pm ↑ Summary HTTP2/Trace.pm »