Class HpackDecoder


  • final class HpackDecoder
    extends java.lang.Object
    • Field Detail

      • DECODE_ULE_128_DECOMPRESSION_EXCEPTION

        private static final Http2Exception DECODE_ULE_128_DECOMPRESSION_EXCEPTION
      • DECODE_ULE_128_TO_LONG_DECOMPRESSION_EXCEPTION

        private static final Http2Exception DECODE_ULE_128_TO_LONG_DECOMPRESSION_EXCEPTION
      • DECODE_ULE_128_TO_INT_DECOMPRESSION_EXCEPTION

        private static final Http2Exception DECODE_ULE_128_TO_INT_DECOMPRESSION_EXCEPTION
      • DECODE_ILLEGAL_INDEX_VALUE

        private static final Http2Exception DECODE_ILLEGAL_INDEX_VALUE
      • INDEX_HEADER_ILLEGAL_INDEX_VALUE

        private static final Http2Exception INDEX_HEADER_ILLEGAL_INDEX_VALUE
      • READ_NAME_ILLEGAL_INDEX_VALUE

        private static final Http2Exception READ_NAME_ILLEGAL_INDEX_VALUE
      • INVALID_MAX_DYNAMIC_TABLE_SIZE

        private static final Http2Exception INVALID_MAX_DYNAMIC_TABLE_SIZE
      • MAX_DYNAMIC_TABLE_SIZE_CHANGE_REQUIRED

        private static final Http2Exception MAX_DYNAMIC_TABLE_SIZE_CHANGE_REQUIRED
      • READ_HEADER_REPRESENTATION

        private static final byte READ_HEADER_REPRESENTATION
        See Also:
        Constant Field Values
      • READ_MAX_DYNAMIC_TABLE_SIZE

        private static final byte READ_MAX_DYNAMIC_TABLE_SIZE
        See Also:
        Constant Field Values
      • READ_INDEXED_HEADER_NAME

        private static final byte READ_INDEXED_HEADER_NAME
        See Also:
        Constant Field Values
      • READ_LITERAL_HEADER_NAME_LENGTH_PREFIX

        private static final byte READ_LITERAL_HEADER_NAME_LENGTH_PREFIX
        See Also:
        Constant Field Values
      • READ_LITERAL_HEADER_NAME_LENGTH

        private static final byte READ_LITERAL_HEADER_NAME_LENGTH
        See Also:
        Constant Field Values
      • READ_LITERAL_HEADER_NAME

        private static final byte READ_LITERAL_HEADER_NAME
        See Also:
        Constant Field Values
      • READ_LITERAL_HEADER_VALUE_LENGTH_PREFIX

        private static final byte READ_LITERAL_HEADER_VALUE_LENGTH_PREFIX
        See Also:
        Constant Field Values
      • READ_LITERAL_HEADER_VALUE_LENGTH

        private static final byte READ_LITERAL_HEADER_VALUE_LENGTH
        See Also:
        Constant Field Values
      • READ_LITERAL_HEADER_VALUE

        private static final byte READ_LITERAL_HEADER_VALUE
        See Also:
        Constant Field Values
      • maxHeaderListSize

        private long maxHeaderListSize
      • maxDynamicTableSize

        private long maxDynamicTableSize
      • encoderMaxDynamicTableSize

        private long encoderMaxDynamicTableSize
      • maxDynamicTableSizeChangeRequired

        private boolean maxDynamicTableSizeChangeRequired
    • Constructor Detail

      • HpackDecoder

        HpackDecoder​(long maxHeaderListSize)
        Create a new instance.
        Parameters:
        maxHeaderListSize - This is the only setting that can be configured before notifying the peer. This is because SETTINGS_MAX_HEADER_LIST_SIZE allows a lower than advertised limit from being enforced, and the default limit is unlimited (which is dangerous).
      • HpackDecoder

        HpackDecoder​(long maxHeaderListSize,
                     int maxHeaderTableSize)
        Exposed Used for testing only! Default values used in the initial settings frame are overridden intentionally for testing but violate the RFC if used outside the scope of testing.
    • Method Detail

      • decode

        public void decode​(int streamId,
                           ByteBuf in,
                           Http2Headers headers,
                           boolean validateHeaders)
                    throws Http2Exception
        Decode the header block into header fields.

        This method assumes the entire header block is contained in in.

        Throws:
        Http2Exception
      • setMaxHeaderTableSize

        public void setMaxHeaderTableSize​(long maxHeaderTableSize)
                                   throws Http2Exception
        Set the maximum table size. If this is below the maximum size of the dynamic table used by the encoder, the beginning of the next header block MUST signal this change.
        Throws:
        Http2Exception
      • getMaxHeaderListSize

        public long getMaxHeaderListSize()
      • getMaxHeaderTableSize

        public long getMaxHeaderTableSize()
        Return the maximum table size. This is the maximum size allowed by both the encoder and the decoder.
      • length

        int length()
        Return the number of header fields in the dynamic table. Exposed for testing.
      • size

        long size()
        Return the size of the dynamic table. Exposed for testing.
      • getHeaderField

        HpackHeaderField getHeaderField​(int index)
        Return the header field at the given index. Exposed for testing.
      • notEnoughDataException

        private static java.lang.IllegalArgumentException notEnoughDataException​(ByteBuf in)
      • decodeULE128

        static int decodeULE128​(ByteBuf in,
                                int result)
                         throws Http2Exception
        Unsigned Little Endian Base 128 Variable-Length Integer Encoding

        Visible for testing only!

        Throws:
        Http2Exception
      • decodeULE128

        static long decodeULE128​(ByteBuf in,
                                 long result)
                          throws Http2Exception
        Unsigned Little Endian Base 128 Variable-Length Integer Encoding

        Visible for testing only!

        Throws:
        Http2Exception