1package Protocol::HTTP2::Frame::Continuation;
2use strict;
3use warnings;
4use Protocol::HTTP2::Constants qw(:flags :errors);
5use Protocol::HTTP2::Trace qw(tracer);
6
7sub 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
21    $con->stream_header_block( $frame_ref->{stream},
22        substr( $$buf_ref, $buf_offset, $length ) );
23
24    # Stream header block complete
25    $con->stream_headers_done( $frame_ref->{stream} )
26      or return undef
27      if $frame_ref->{flags} & END_HEADERS;
28
29    return $length;
30
31}
32
33sub encode {
34    my ( $con, $flags_ref, $stream, $data_ref ) = @_;
35    return $$data_ref;
36}
37
381;
39