Package io.netty.handler.codec.http2
Class HpackDecoder
java.lang.Object
io.netty.handler.codec.http2.HpackDecoder
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enum
HTTP/2 header types.private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Http2Exception
private static final Http2Exception
private static final Http2Exception
private static final Http2Exception
private long
private final HpackDynamicTable
private final HpackHuffmanDecoder
private static final Http2Exception
private static final Http2Exception
private static final Http2Exception
private long
private boolean
private long
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final Http2Exception
-
Constructor Summary
ConstructorsConstructorDescriptionHpackDecoder
(long maxHeaderListSize) Create a new instance.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 Summary
Modifier and TypeMethodDescription(package private) void
decode
(int streamId, ByteBuf in, Http2Headers headers, boolean validateHeaders) Decode the header block into header fields.private void
decode
(ByteBuf in, HpackDecoder.Http2HeadersSink sink) private void
(package private) static int
decodeULE128
(ByteBuf in, int result) Unsigned Little Endian Base 128 Variable-Length Integer Encoding(package private) static long
decodeULE128
(ByteBuf in, long result) Unsigned Little Endian Base 128 Variable-Length Integer Encoding(package private) HpackHeaderField
getHeaderField
(int index) Return the header field at the given index.private HpackHeaderField
getIndexedHeader
(int index) (package private) long
(package private) long
Return the maximum table size.private void
insertHeader
(HpackDecoder.Http2HeadersSink sink, AsciiString name, AsciiString value, HpackUtil.IndexType indexType) (package private) int
length()
Return the number of header fields in the dynamic table.private static IllegalArgumentException
private AsciiString
readName
(int index) private AsciiString
readStringLiteral
(ByteBuf in, int length, boolean huffmanEncoded) private void
setDynamicTableSize
(long dynamicTableSize) (package private) void
setMaxHeaderListSize
(long maxHeaderListSize) (package private) void
setMaxHeaderTableSize
(long maxHeaderTableSize) Set the maximum table size.(package private) long
size()
Return the size of the dynamic table.private static HpackDecoder.HeaderType
validateHeader
(int streamId, AsciiString name, CharSequence value, HpackDecoder.HeaderType previousHeaderType)
-
Field Details
-
DECODE_ULE_128_DECOMPRESSION_EXCEPTION
-
DECODE_ULE_128_TO_LONG_DECOMPRESSION_EXCEPTION
-
DECODE_ULE_128_TO_INT_DECOMPRESSION_EXCEPTION
-
DECODE_ILLEGAL_INDEX_VALUE
-
INDEX_HEADER_ILLEGAL_INDEX_VALUE
-
READ_NAME_ILLEGAL_INDEX_VALUE
-
INVALID_MAX_DYNAMIC_TABLE_SIZE
-
MAX_DYNAMIC_TABLE_SIZE_CHANGE_REQUIRED
-
READ_HEADER_REPRESENTATION
private static final byte READ_HEADER_REPRESENTATION- See Also:
-
READ_INDEXED_HEADER
private static final byte READ_INDEXED_HEADER- See Also:
-
READ_INDEXED_HEADER_NAME
private static final byte READ_INDEXED_HEADER_NAME- See Also:
-
READ_LITERAL_HEADER_NAME_LENGTH_PREFIX
private static final byte READ_LITERAL_HEADER_NAME_LENGTH_PREFIX- See Also:
-
READ_LITERAL_HEADER_NAME_LENGTH
private static final byte READ_LITERAL_HEADER_NAME_LENGTH- See Also:
-
READ_LITERAL_HEADER_NAME
private static final byte READ_LITERAL_HEADER_NAME- See Also:
-
READ_LITERAL_HEADER_VALUE_LENGTH_PREFIX
private static final byte READ_LITERAL_HEADER_VALUE_LENGTH_PREFIX- See Also:
-
READ_LITERAL_HEADER_VALUE_LENGTH
private static final byte READ_LITERAL_HEADER_VALUE_LENGTH- See Also:
-
READ_LITERAL_HEADER_VALUE
private static final byte READ_LITERAL_HEADER_VALUE- See Also:
-
huffmanDecoder
-
hpackDynamicTable
-
maxHeaderListSize
private long maxHeaderListSize -
maxDynamicTableSize
private long maxDynamicTableSize -
encoderMaxDynamicTableSize
private long encoderMaxDynamicTableSize -
maxDynamicTableSizeChangeRequired
private boolean maxDynamicTableSizeChangeRequired
-
-
Constructor Details
-
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 Details
-
decode
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
-
decodeDynamicTableSizeUpdates
- Throws:
Http2Exception
-
decode
- Throws:
Http2Exception
-
setMaxHeaderTableSize
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
-
setMaxHeaderListSize
- Throws:
Http2Exception
-
getMaxHeaderListSize
long getMaxHeaderListSize() -
getMaxHeaderTableSize
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
Return the header field at the given index. Exposed for testing. -
setDynamicTableSize
- Throws:
Http2Exception
-
validateHeader
private static HpackDecoder.HeaderType validateHeader(int streamId, AsciiString name, CharSequence value, HpackDecoder.HeaderType previousHeaderType) throws Http2Exception - Throws:
Http2Exception
-
readName
- Throws:
Http2Exception
-
getIndexedHeader
- Throws:
Http2Exception
-
insertHeader
private void insertHeader(HpackDecoder.Http2HeadersSink sink, AsciiString name, AsciiString value, HpackUtil.IndexType indexType) -
readStringLiteral
private AsciiString readStringLiteral(ByteBuf in, int length, boolean huffmanEncoded) throws Http2Exception - Throws:
Http2Exception
-
notEnoughDataException
-
decodeULE128
Unsigned Little Endian Base 128 Variable-Length Integer EncodingVisible for testing only!
- Throws:
Http2Exception
-
decodeULE128
Unsigned Little Endian Base 128 Variable-Length Integer EncodingVisible for testing only!
- Throws:
Http2Exception
-