| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 45 | 12 | return $payload; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 13 | 1; | |||||||||