Home / Function/ decode() — netty Function Reference

decode() — netty Function Reference

Architecture documentation for the decode() function in QpackDecoderHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  8bbbe4c9_5fd7_f3b1_ca6e_607dce014b40["decode()"]
  92ae2c3b_b091_d906_04be_f3716840379f["QpackDecoderHandler"]
  8bbbe4c9_5fd7_f3b1_ca6e_607dce014b40 -->|defined in| 92ae2c3b_b091_d906_04be_f3716840379f
  style 8bbbe4c9_5fd7_f3b1_ca6e_607dce014b40 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http3/src/main/java/io/netty/handler/codec/http3/QpackDecoderHandler.java lines 38–126

    @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;
            }
            if (increment < 0) {
                // Not enough readable bytes
                return;
            }
            try {
                qpackEncoder.insertCountIncrement(increment);
            } catch (QpackException e) {
                connectionError(ctx, new Http3Exception(QPACK_DECODER_STREAM_ERROR,
                        "Insert count increment decode failed.", e), true);

Domain

Subdomains

Frequently Asked Questions

What does decode() do?
decode() is a function in the netty codebase, defined in codec-http3/src/main/java/io/netty/handler/codec/http3/QpackDecoderHandler.java.
Where is decode() defined?
decode() is defined in codec-http3/src/main/java/io/netty/handler/codec/http3/QpackDecoderHandler.java at line 38.

Analyze Your Own Codebase

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

Try Supermodel Free