Home / Class/ QpackDecoderHandler Class — netty Architecture

QpackDecoderHandler Class — netty Architecture

Architecture documentation for the QpackDecoderHandler class in QpackDecoderHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  92ae2c3b_b091_d906_04be_f3716840379f["QpackDecoderHandler"]
  6cee58a7_e32b_c999_18f8_2b68c68d3ece["QpackDecoderHandler.java"]
  92ae2c3b_b091_d906_04be_f3716840379f -->|defined in| 6cee58a7_e32b_c999_18f8_2b68c68d3ece
  fb5687c7_7857_b005_3c88_00f499f81cdf["QpackDecoderHandler()"]
  92ae2c3b_b091_d906_04be_f3716840379f -->|method| fb5687c7_7857_b005_3c88_00f499f81cdf
  8bbbe4c9_5fd7_f3b1_ca6e_607dce014b40["decode()"]
  92ae2c3b_b091_d906_04be_f3716840379f -->|method| 8bbbe4c9_5fd7_f3b1_ca6e_607dce014b40
  24642684_794a_6184_6c8c_bf18005901a9["channelReadComplete()"]
  92ae2c3b_b091_d906_04be_f3716840379f -->|method| 24642684_794a_6184_6c8c_bf18005901a9
  f7f993c4_f19e_5d74_43eb_dc48ddf8884e["userEventTriggered()"]
  92ae2c3b_b091_d906_04be_f3716840379f -->|method| f7f993c4_f19e_5d74_43eb_dc48ddf8884e
  8c6b19b0_c0ca_a120_b4df_5d73dc8b7eb6["channelInactive()"]
  92ae2c3b_b091_d906_04be_f3716840379f -->|method| 8c6b19b0_c0ca_a120_b4df_5d73dc8b7eb6

Relationship Graph

Source Code

codec-http3/src/main/java/io/netty/handler/codec/http3/QpackDecoderHandler.java lines 29–152

final class QpackDecoderHandler extends ByteToMessageDecoder {

    private boolean discard;
    private final QpackEncoder qpackEncoder;

    QpackDecoderHandler(QpackEncoder qpackEncoder) {
        this.qpackEncoder = qpackEncoder;
    }

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        if (!in.isReadable()) {
            return;
        }
        if (discard) {
            in.skipBytes(in.readableBytes());
            return;
        }

        byte b = in.getByte(in.readerIndex());

        // 4.4.1. Section Acknowledgment
        //
        //   0   1   2   3   4   5   6   7
        // +---+---+---+---+---+---+---+---+
        // | 1 |      Stream ID (7+)       |
        // +---+---------------------------+
        if ((b & 0b1000_0000) == 0b1000_0000) {
            long streamId = QpackUtil.decodePrefixedInteger(in, 7);
            if (streamId < 0) {
                // Not enough readable bytes
                return;
            }
            try {
                qpackEncoder.sectionAcknowledgment(streamId);
            } catch (QpackException e) {
                connectionError(ctx, new Http3Exception(QPACK_DECODER_STREAM_ERROR,
                                "Section acknowledgment decode failed.", e), true);
            }
            return;
        }

        // 4.4.2. Stream Cancellation
        //
        //   0   1   2   3   4   5   6   7
        // +---+---+---+---+---+---+---+---+
        // | 0 | 1 |     Stream ID (6+)    |
        // +---+---+-----------------------+
        if ((b & 0b1100_0000) == 0b0100_0000) {
            long streamId = QpackUtil.decodePrefixedInteger(in, 6);
            if (streamId < 0) {
                // Not enough readable bytes
                return;
            }
            try {
                qpackEncoder.streamCancellation(streamId);
            } catch (QpackException e) {
                connectionError(ctx, new Http3Exception(QPACK_DECODER_STREAM_ERROR,
                        "Stream cancellation decode failed.", e), true);
            }
            return;
        }

        // 4.4.3. Insert Count Increment
        //
        //   0   1   2   3   4   5   6   7
        // +---+---+---+---+---+---+---+---+
        // | 0 | 0 |     Increment (6+)    |
        // +---+---+-----------------------+
        if ((b & 0b1100_0000) == 0b0000_0000) {
            int increment = decodePrefixedIntegerAsInt(in, 6);
            if (increment == 0) {
                discard = true;
                // Zero is not allowed as an increment
                // https://www.rfc-editor.org/rfc/rfc9204.html#name-insert-count-increment
                // Increment is an unsigned integer, so only 0 is the invalid value.
                // https://www.rfc-editor.org/rfc/rfc7541#section-5
                connectionError(ctx, QPACK_DECODER_STREAM_ERROR,
                        "Invalid increment '" + increment + "'.",  false);
                return;
            }

Frequently Asked Questions

What is the QpackDecoderHandler class?
QpackDecoderHandler is a class in the netty codebase, defined in codec-http3/src/main/java/io/netty/handler/codec/http3/QpackDecoderHandler.java.
Where is QpackDecoderHandler defined?
QpackDecoderHandler is defined in codec-http3/src/main/java/io/netty/handler/codec/http3/QpackDecoderHandler.java at line 29.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free