Home / Function/ decodeRequiredInsertCount() — netty Function Reference

decodeRequiredInsertCount() — netty Function Reference

Architecture documentation for the decodeRequiredInsertCount() function in QpackDecoder.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  17f145b9_9c07_732a_f118_6a866c5843ea["decodeRequiredInsertCount()"]
  90fa2d3f_8d04_4c74_e2ce_52229be77194["QpackDecoder"]
  17f145b9_9c07_732a_f118_6a866c5843ea -->|defined in| 90fa2d3f_8d04_4c74_e2ce_52229be77194
  678f973e_104e_7340_6c3b_b4ef23003fe0["decode()"]
  678f973e_104e_7340_6c3b_b4ef23003fe0 -->|calls| 17f145b9_9c07_732a_f118_6a866c5843ea
  style 17f145b9_9c07_732a_f118_6a866c5843ea fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http3/src/main/java/io/netty/handler/codec/http3/QpackDecoder.java lines 408–457

    int decodeRequiredInsertCount(QpackAttributes qpackAttributes, ByteBuf buf) throws QpackException {
        final long encodedInsertCount = QpackUtil.decodePrefixedInteger(buf, 8);
        assert encodedInsertCount >= 0;
        // https://www.rfc-editor.org/rfc/rfc9204.html#name-required-insert-count
        // FullRange = 2 * MaxEntries
        //   if EncodedInsertCount == 0:
        //      ReqInsertCount = 0
        //   else:
        //      if EncodedInsertCount > FullRange:
        //         Error
        //      MaxValue = TotalNumberOfInserts + MaxEntries
        //
        //      # MaxWrapped is the largest possible value of
        //      # ReqInsertCount that is 0 mod 2 * MaxEntries
        //      MaxWrapped = floor(MaxValue / FullRange) * FullRange
        //      ReqInsertCount = MaxWrapped + EncodedInsertCount - 1
        //
        //      # If ReqInsertCount exceeds MaxValue, the Encoder's value
        //      # must have wrapped one fewer time
        //      if ReqInsertCount > MaxValue:
        //         if ReqInsertCount <= FullRange:
        //            Error
        //         ReqInsertCount -= FullRange
        //
        //      # Value of 0 must be encoded as 0.
        //      if ReqInsertCount == 0:
        //         Error
        if (encodedInsertCount == 0) {
            return 0;
        }
        if (qpackAttributes.dynamicTableDisabled() || encodedInsertCount > fullRange) {
            throw INVALID_REQUIRED_INSERT_COUNT;
        }

        final long maxValue = dynamicTable.insertCount() + maxEntries;
        final long maxWrapped = floorDiv(maxValue, fullRange) * fullRange;
        long requiredInsertCount = maxWrapped + encodedInsertCount - 1;

        if (requiredInsertCount > maxValue) {
            if (requiredInsertCount <= fullRange) {
                throw INVALID_REQUIRED_INSERT_COUNT;
            }
            requiredInsertCount -= fullRange;
        }
        // requiredInsertCount can not be negative as encodedInsertCount read from the buffer can not be negative.
        if (requiredInsertCount == 0) {
            throw INVALID_REQUIRED_INSERT_COUNT;
        }
        return toIntOrThrow(requiredInsertCount);
    }

Domain

Subdomains

Called By

Frequently Asked Questions

What does decodeRequiredInsertCount() do?
decodeRequiredInsertCount() is a function in the netty codebase, defined in codec-http3/src/main/java/io/netty/handler/codec/http3/QpackDecoder.java.
Where is decodeRequiredInsertCount() defined?
decodeRequiredInsertCount() is defined in codec-http3/src/main/java/io/netty/handler/codec/http3/QpackDecoder.java at line 408.
What calls decodeRequiredInsertCount()?
decodeRequiredInsertCount() is called by 1 function(s): decode.

Analyze Your Own Codebase

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

Try Supermodel Free