Class DefaultHttp2HeadersDecoder
java.lang.Object
io.netty.handler.codec.http2.DefaultHttp2HeadersDecoder
- All Implemented Interfaces:
Http2HeadersDecoder, Http2HeadersDecoder.Configuration
public class DefaultHttp2HeadersDecoder
extends Object
implements Http2HeadersDecoder, Http2HeadersDecoder.Configuration
-
Nested Class Summary
Nested classes/interfaces inherited from interface Http2HeadersDecoder
Http2HeadersDecoder.Configuration -
Constructor Summary
ConstructorsConstructorDescriptionDefaultHttp2HeadersDecoder(boolean validateHeaders) Create a new instance.DefaultHttp2HeadersDecoder(boolean validateHeaders, boolean validateHeaderValues) Create a new instance.DefaultHttp2HeadersDecoder(boolean validateHeaders, boolean validateHeaderValues, long maxHeaderListSize) Create a new instance.DefaultHttp2HeadersDecoder(boolean validateHeaders, long maxHeaderListSize) Create a new instance.DefaultHttp2HeadersDecoder(boolean validateHeaders, long maxHeaderListSize, int initialHuffmanDecodeCapacity) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionGet theHttp2HeadersDecoder.Configurationfor thisHttp2HeadersDecoderdecodeHeaders(int streamId, ByteBuf headerBlock) Decodes the given headers block and returns the headers.longRepresents the value for SETTINGS_MAX_HEADER_LIST_SIZE.voidmaxHeaderListSize(long max, long goAwayMax) Configure the maximum allowed size in bytes of each set of headers.longRepresents the upper bound in bytes for a set of headers before aGO_AWAYshould be sent.longRepresents the value for SETTINGS_HEADER_TABLE_SIZE.voidmaxHeaderTableSize(long max) Represents the value for SETTINGS_HEADER_TABLE_SIZE.protected Http2HeadersCreate a newHttp2Headersobject which will store the results of the decode operation.protected final intA weighted moving average estimating how many headers are expected during the decode process.protected final booleanDetermines if the headers should be validated as a result of the decode operation.protected booleanDetermines if the header values should be validated as a result of the decode operation.
-
Constructor Details
-
DefaultHttp2HeadersDecoder
public DefaultHttp2HeadersDecoder() -
DefaultHttp2HeadersDecoder
public DefaultHttp2HeadersDecoder(boolean validateHeaders) Create a new instance.- Parameters:
validateHeaders-trueto validate headers are valid according to the RFC.
-
DefaultHttp2HeadersDecoder
public DefaultHttp2HeadersDecoder(boolean validateHeaders, boolean validateHeaderValues) Create a new instance.- Parameters:
validateHeaders-trueto validate headers are valid according to the RFC. This validates everything except header values.validateHeaderValues-trueto validate that header values are valid according to the RFC. Since this is potentially expensive, it can be enabled separately fromvalidateHeaders.
-
DefaultHttp2HeadersDecoder
public DefaultHttp2HeadersDecoder(boolean validateHeaders, long maxHeaderListSize) Create a new instance.- Parameters:
validateHeaders-trueto validate headers are valid according to the RFC.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).
-
DefaultHttp2HeadersDecoder
public DefaultHttp2HeadersDecoder(boolean validateHeaders, boolean validateHeaderValues, long maxHeaderListSize) Create a new instance.- Parameters:
validateHeaders-trueto validate headers are valid according to the RFC. This validates everything except header values.validateHeaderValues-trueto validate that header values are valid according to the RFC. Since this is potentially expensive, it can be enabled separately fromvalidateHeaders.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).
-
DefaultHttp2HeadersDecoder
public DefaultHttp2HeadersDecoder(boolean validateHeaders, long maxHeaderListSize, @Deprecated int initialHuffmanDecodeCapacity) Create a new instance.- Parameters:
validateHeaders-trueto validate headers are valid according to the RFC. This validates everything except header values.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).initialHuffmanDecodeCapacity- Does nothing, do not use.
-
-
Method Details
-
maxHeaderTableSize
Description copied from interface:Http2HeadersDecoder.ConfigurationRepresents the value for SETTINGS_HEADER_TABLE_SIZE. This method should only be called by Netty (not users) as a result of a receiving aSETTINGSframe.- Specified by:
maxHeaderTableSizein interfaceHttp2HeadersDecoder.Configuration- Throws:
Http2Exception
-
maxHeaderTableSize
public long maxHeaderTableSize()Description copied from interface:Http2HeadersDecoder.ConfigurationRepresents the value for SETTINGS_HEADER_TABLE_SIZE. The initial value returned by this method must beHttp2CodecUtil.DEFAULT_HEADER_TABLE_SIZE.- Specified by:
maxHeaderTableSizein interfaceHttp2HeadersDecoder.Configuration
-
maxHeaderListSize
Description copied from interface:Http2HeadersDecoder.ConfigurationConfigure the maximum allowed size in bytes of each set of headers.This method should only be called by Netty (not users) as a result of a receiving a
SETTINGSframe.- Specified by:
maxHeaderListSizein interfaceHttp2HeadersDecoder.Configuration- Parameters:
max- SETTINGS_MAX_HEADER_LIST_SIZE. If this limit is exceeded the implementation should attempt to keep the HPACK header tables up to date by processing data from the peer, but aRST_STREAMframe will be sent for the offending stream.goAwayMax- Must be>= max. AGO_AWAYframe will be generated if this limit is exceeded for any particular stream.- Throws:
Http2Exception- if limits exceed the RFC's boundaries ormax > goAwayMax.
-
maxHeaderListSize
public long maxHeaderListSize()Description copied from interface:Http2HeadersDecoder.ConfigurationRepresents the value for SETTINGS_MAX_HEADER_LIST_SIZE.- Specified by:
maxHeaderListSizein interfaceHttp2HeadersDecoder.Configuration
-
maxHeaderListSizeGoAway
public long maxHeaderListSizeGoAway()Description copied from interface:Http2HeadersDecoder.ConfigurationRepresents the upper bound in bytes for a set of headers before aGO_AWAYshould be sent. This will be<=SETTINGS_MAX_HEADER_LIST_SIZE.- Specified by:
maxHeaderListSizeGoAwayin interfaceHttp2HeadersDecoder.Configuration
-
configuration
Description copied from interface:Http2HeadersDecoderGet theHttp2HeadersDecoder.Configurationfor thisHttp2HeadersDecoder- Specified by:
configurationin interfaceHttp2HeadersDecoder
-
decodeHeaders
Description copied from interface:Http2HeadersDecoderDecodes the given headers block and returns the headers.- Specified by:
decodeHeadersin interfaceHttp2HeadersDecoder- Throws:
Http2Exception
-
numberOfHeadersGuess
protected final int numberOfHeadersGuess()A weighted moving average estimating how many headers are expected during the decode process.- Returns:
- an estimate of how many headers are expected during the decode process.
-
validateHeaders
protected final boolean validateHeaders()Determines if the headers should be validated as a result of the decode operation.Note: This does not include validation of header values, since that is potentially expensive to do. Value validation is instead enabled separately.
- Returns:
trueif the headers should be validated as a result of the decode operation.
-
validateHeaderValues
protected boolean validateHeaderValues()Determines if the header values should be validated as a result of the decode operation.Note: This only validates the values of headers. All other header validations are instead enabled separately.
- Returns:
trueif the header values should be validated as a result of the decode operation.
-
newHeaders
Create a newHttp2Headersobject which will store the results of the decode operation.- Returns:
- a new
Http2Headersobject which will store the results of the decode operation.
-