Home / Function/ decode() — netty Function Reference

decode() — netty Function Reference

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

Function java Buffer Allocators calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  086b858f_1c2b_8983_bdf4_54198c4b3940["decode()"]
  11e6398c_ef5c_d1f6_7673_0efaf04b0086["QpackEncoderHandler"]
  086b858f_1c2b_8983_bdf4_54198c4b3940 -->|defined in| 11e6398c_ef5c_d1f6_7673_0efaf04b0086
  64bcc6c7_2235_7bfb_14f4_31ed2137f9be["CharSequence()"]
  64bcc6c7_2235_7bfb_14f4_31ed2137f9be -->|calls| 086b858f_1c2b_8983_bdf4_54198c4b3940
  f180b347_49d9_5c42_8aff_a8f0538274d8["handleDecodeFailure()"]
  086b858f_1c2b_8983_bdf4_54198c4b3940 -->|calls| f180b347_49d9_5c42_8aff_a8f0538274d8
  style 086b858f_1c2b_8983_bdf4_54198c4b3940 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http3/src/main/java/io/netty/handler/codec/http3/QpackEncoderHandler.java lines 46–194

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

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

        // 4.3.1. Set Dynamic Table Capacity
        //
        //   0   1   2   3   4   5   6   7
        //+---+---+---+---+---+---+---+---+
        //| 0 | 0 | 1 |   Capacity (5+)   |
        //+---+---+---+-------------------+
        if ((b & 0b1110_0000) == 0b0010_0000) {
            // new capacity
            long capacity = QpackUtil.decodePrefixedInteger(in, 5);
            if (capacity < 0) {
                // Not enough readable bytes
                return;
            }

            try {
                qpackDecoder.setDynamicTableCapacity(capacity);
            } catch (QpackException e) {
                handleDecodeFailure(ctx, e, "setDynamicTableCapacity failed.");
            }
            return;
        }

        final QpackAttributes qpackAttributes = Http3.getQpackAttributes(ctx.channel().parent());
        assert qpackAttributes != null;
        if (!qpackAttributes.dynamicTableDisabled() && !qpackAttributes.decoderStreamAvailable()) {
            // We need the decoder stream to update the decoder with these instructions.
            return;
        }
        final QuicStreamChannel decoderStream = qpackAttributes.decoderStream();

        // 4.3.2. Insert With Name Reference
        //
        //      0   1   2   3   4   5   6   7
        //   +---+---+---+---+---+---+---+---+
        //   | 1 | T |    Name Index (6+)    |
        //   +---+---+-----------------------+
        //   | H |     Value Length (7+)     |
        //   +---+---------------------------+
        //   |  Value String (Length bytes)  |
        //   +-------------------------------+
        if ((b & 0b1000_0000) == 0b1000_0000) {
            int readerIndex = in.readerIndex();
            // T == 1 implies static table index.
            // https://www.rfc-editor.org/rfc/rfc9204.html#name-insert-with-name-reference
            final boolean isStaticTableIndex = QpackUtil.firstByteEquals(in, (byte) 0b1100_0000);
            final int nameIdx = decodePrefixedIntegerAsInt(in, 6);
            if (nameIdx < 0) {
                // Not enough readable bytes
                return;
            }

            CharSequence value = decodeLiteralValue(in);
            if (value == null) {
                // Reset readerIndex
                in.readerIndex(readerIndex);
                // Not enough readable bytes
                return;
            }
            try {
                qpackDecoder.insertWithNameReference(decoderStream, isStaticTableIndex, nameIdx,
                        value);
            } catch (QpackException e) {
                handleDecodeFailure(ctx, e, "insertWithNameReference failed.");
            }
            return;
        }
        // 4.3.3. Insert With Literal Name
        //
        //      0   1   2   3   4   5   6   7

Domain

Subdomains

Called By

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/QpackEncoderHandler.java.
Where is decode() defined?
decode() is defined in codec-http3/src/main/java/io/netty/handler/codec/http3/QpackEncoderHandler.java at line 46.
What does decode() call?
decode() calls 1 function(s): handleDecodeFailure.
What calls decode()?
decode() is called by 1 function(s): CharSequence.

Analyze Your Own Codebase

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

Try Supermodel Free