Package io.netty.handler.codec.http2
Class HpackDecoder
- java.lang.Object
-
- io.netty.handler.codec.http2.HpackDecoder
-
final class HpackDecoder extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
HpackDecoder.HeaderType
HTTP/2 header types.private static class
HpackDecoder.Http2HeadersSink
-
Field Summary
-
Constructor Summary
Constructors Constructor Description HpackDecoder(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (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
decodeDynamicTableSizeUpdates(ByteBuf in)
(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
getMaxHeaderListSize()
(package private) long
getMaxHeaderTableSize()
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 java.lang.IllegalArgumentException
notEnoughDataException(ByteBuf in)
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, java.lang.CharSequence value, HpackDecoder.HeaderType previousHeaderType)
-
-
-
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_INDEXED_HEADER
private static final byte READ_INDEXED_HEADER
- 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
-
huffmanDecoder
private final HpackHuffmanDecoder huffmanDecoder
-
hpackDynamicTable
private final HpackDynamicTable hpackDynamicTable
-
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
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
private void decodeDynamicTableSizeUpdates(ByteBuf in) throws Http2Exception
- Throws:
Http2Exception
-
decode
private void decode(ByteBuf in, HpackDecoder.Http2HeadersSink sink) throws Http2Exception
- Throws:
Http2Exception
-
setMaxHeaderTableSize
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
-
setMaxHeaderListSize
void setMaxHeaderListSize(long maxHeaderListSize) throws Http2Exception
- 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
HpackHeaderField getHeaderField(int index)
Return the header field at the given index. Exposed for testing.
-
setDynamicTableSize
private void setDynamicTableSize(long dynamicTableSize) throws Http2Exception
- Throws:
Http2Exception
-
validateHeader
private static HpackDecoder.HeaderType validateHeader(int streamId, AsciiString name, java.lang.CharSequence value, HpackDecoder.HeaderType previousHeaderType) throws Http2Exception
- Throws:
Http2Exception
-
readName
private AsciiString readName(int index) throws Http2Exception
- Throws:
Http2Exception
-
getIndexedHeader
private HpackHeaderField getIndexedHeader(int index) throws Http2Exception
- 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
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 EncodingVisible for testing only!
- Throws:
Http2Exception
-
decodeULE128
static long decodeULE128(ByteBuf in, long result) throws Http2Exception
Unsigned Little Endian Base 128 Variable-Length Integer EncodingVisible for testing only!
- Throws:
Http2Exception
-
-