Debian Codegraph @

lib/Protocol/HTTP2/Frame/Continuation.pm

raw
1 package Protocol::HTTP2::Frame::Continuation;
2 use strict;
3 use warnings;
4 use Protocol::HTTP2::Constants qw(:flags :errors :settings);
5 use Protocol::HTTP2::Trace qw(tracer);
6
7 sub decode {
8 my ( $con, $buf_ref, $buf_offset, $length ) = @_;
9 my $frame_ref = $con->decode_context->{frame};
10
11 # Protocol errors
12 if (
13 # CONTINUATION frames MUST be associated with a stream
14 $frame_ref->{stream} == 0
15 )
16 {
17 $con->error(PROTOCOL_ERROR);
18 return undef;
19 }
20 if (
21 # Headers compressed size already exceeded decompressed limit
22 length( $con->stream_header_block( $frame_ref->{stream} ) ) + $length >
23 $con->dec_setting(SETTINGS_MAX_HEADER_LIST_SIZE)
24 )
25 {
26 $con->error(ENHANCE_YOUR_CALM);
27 return undef;
28 }
29
30 $con->stream_header_block_add( $frame_ref->{stream},
31 substr( $$buf_ref, $buf_offset, $length ) )
32 or return undef;
33
34 # Stream header block complete
35 $con->stream_headers_done( $frame_ref->{stream} )
36 or return undef
37 if $frame_ref->{flags} & END_HEADERS;
38
39 return $length;
40
41 }
42
43 sub encode {
44 my ( $con, $flags_ref, $stream, $data_ref ) = @_;
45 return $$data_ref;
46 }
47
48 1;