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 classHpackDecoder.HeaderTypeHTTP/2 header types.private static classHpackDecoder.Http2HeadersSinkprivate static interfaceHpackDecoder.Sink
-
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 Deprecated Methods Modifier and Type Method Description voiddecode(int streamId, ByteBuf in, Http2Headers headers, boolean validateHeaders)Decode the header block into header fields.private voiddecode(ByteBuf in, HpackDecoder.Sink sink)(package private) static intdecodeULE128(ByteBuf in, int result)Unsigned Little Endian Base 128 Variable-Length Integer Encoding(package private) static longdecodeULE128(ByteBuf in, long result)Unsigned Little Endian Base 128 Variable-Length Integer Encoding(package private) HpackHeaderFieldgetHeaderField(int index)Return the header field at the given index.private HpackHeaderFieldgetIndexedHeader(int index)longgetMaxHeaderListSize()longgetMaxHeaderTableSize()Return the maximum table size.private voidinsertHeader(HpackDecoder.Sink sink, java.lang.CharSequence name, java.lang.CharSequence value, HpackUtil.IndexType indexType)(package private) intlength()Return the number of header fields in the dynamic table.private static java.lang.IllegalArgumentExceptionnotEnoughDataException(ByteBuf in)private java.lang.CharSequencereadName(int index)private java.lang.CharSequencereadStringLiteral(ByteBuf in, int length, boolean huffmanEncoded)private voidsetDynamicTableSize(long dynamicTableSize)voidsetMaxHeaderListSize(long maxHeaderListSize)voidsetMaxHeaderListSize(long maxHeaderListSize, long maxHeaderListSizeGoAway)Deprecated.usesetMaxHeaderListSize(long);maxHeaderListSizeGoAwayis ignoredvoidsetMaxHeaderTableSize(long maxHeaderTableSize)Set the maximum table size.(package private) longsize()Return the size of the dynamic table.private static HpackDecoder.HeaderTypevalidate(int streamId, java.lang.CharSequence name, 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_MAX_DYNAMIC_TABLE_SIZE
private static final byte READ_MAX_DYNAMIC_TABLE_SIZE
- 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
public void decode(int streamId, ByteBuf in, Http2Headers headers, boolean validateHeaders) throws Http2ExceptionDecode the header block into header fields.This method assumes the entire header block is contained in
in.- Throws:
Http2Exception
-
decode
private void decode(ByteBuf in, HpackDecoder.Sink sink) throws Http2Exception
- Throws:
Http2Exception
-
setMaxHeaderTableSize
public void setMaxHeaderTableSize(long maxHeaderTableSize) throws Http2ExceptionSet 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
@Deprecated public void setMaxHeaderListSize(long maxHeaderListSize, long maxHeaderListSizeGoAway) throws Http2ExceptionDeprecated.usesetMaxHeaderListSize(long);maxHeaderListSizeGoAwayis ignored- Throws:
Http2Exception
-
setMaxHeaderListSize
public void setMaxHeaderListSize(long maxHeaderListSize) throws Http2Exception- 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.
-
setDynamicTableSize
private void setDynamicTableSize(long dynamicTableSize) throws Http2Exception- Throws:
Http2Exception
-
validate
private static HpackDecoder.HeaderType validate(int streamId, java.lang.CharSequence name, HpackDecoder.HeaderType previousHeaderType) throws Http2Exception
- Throws:
Http2Exception
-
readName
private java.lang.CharSequence readName(int index) throws Http2Exception- Throws:
Http2Exception
-
getIndexedHeader
private HpackHeaderField getIndexedHeader(int index) throws Http2Exception
- Throws:
Http2Exception
-
insertHeader
private void insertHeader(HpackDecoder.Sink sink, java.lang.CharSequence name, java.lang.CharSequence value, HpackUtil.IndexType indexType)
-
readStringLiteral
private java.lang.CharSequence 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
-
-