Top Fields Constructors Methods
io.netty5.handler.codec.http2

public Class DefaultHttp2HeadersDecoder

extends Object
implements Http2HeadersDecoder, Configuration
Class Inheritance
All Implemented Interfaces
io.netty5.handler.codec.http2.Http2HeadersDecoder.Configuration, io.netty5.handler.codec.http2.Http2HeadersDecoder
Annotations
@UnstableApi
Imports
io.netty5.buffer.Buffer, io.netty5.handler.codec.http2.headers.Http2Headers, io.netty5.util.internal.UnstableApi

Field Summary

Modifier and TypeField and Description
private float
headerArraySizeAccumulator

Used to calculate an exponential moving average of header sizes to get an estimate of how large the data structure for storing headers should be.

private static final float
private static final float
private final HpackDecoder
private long
private final boolean
private final boolean

Constructor Summary

AccessConstructor and Description
public
public
DefaultHttp2HeadersDecoder(boolean
true to validate headers are valid according to the RFC.
validateHeaders
)

Create a new instance.

public
DefaultHttp2HeadersDecoder(boolean
true to validate headers are valid according to the RFC. This validates everything except header values.
validateHeaders
,
boolean
true to validate that header values are valid according to the RFC. Since this is potentially expensive, it can be enabled separately from validateHeaders.
validateHeaderValues
)

Create a new instance.

public
DefaultHttp2HeadersDecoder(boolean
true to validate headers are valid according to the RFC.
validateHeaders
,
long
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).
maxHeaderListSize
)

Create a new instance.

public
DefaultHttp2HeadersDecoder(boolean
true to validate headers are valid according to the RFC. This validates everything except header values.
validateHeaders
,
boolean
true to validate that header values are valid according to the RFC. Since this is potentially expensive, it can be enabled separately from validateHeaders.
validateHeaderValues
,
long
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).
maxHeaderListSize
)

Create a new instance.

pack-priv
DefaultHttp2HeadersDecoder(boolean validateHeaders, boolean validateHeaderValues, HpackDecoder hpackDecoder)

Exposed for testing only!

Method Summary

Modifier and TypeMethod and Description
public Http2HeadersDecoder.Configuration
public Http2Headers
decodeHeaders(int streamId, Buffer headerBlock)

Implements io.netty5.handler.codec.http2.Http2HeadersDecoder.decodeHeaders.

Decodes the given headers block and returns the headers.
public void
maxHeaderListSize(long
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 a RST_STREAM frame will be sent for the offending stream.
max
,
long
Must be >= max. A GO_AWAY frame will be generated if this limit is exceeded for any particular stream.
goAwayMax
)

Implements io.netty5.handler.codec.http2.Http2HeadersDecoder.Configuration.maxHeaderListSize.

Configure the maximum allowed size in bytes of each set of headers.
public long
public long
maxHeaderListSizeGoAway()

Implements io.netty5.handler.codec.http2.Http2HeadersDecoder.Configuration.maxHeaderListSizeGoAway.

Represents the upper bound in bytes for a set of headers before a GO_AWAY should be sent.
public void
public long
protected Http2Headers

Returns:

a new Http2Headers object which will store the results of the decode operation.
newHeaders
()

Create a new Http2Headers object which will store the results of the decode operation.

protected final int

Returns:

an estimate of how many headers are expected during the decode process.
numberOfHeadersGuess
()

A weighted moving average estimating how many headers are expected during the decode process.

protected final boolean

Returns:

true if the headers should be validated as a result of the decode operation.
validateHeaders
()

Determines if the headers should be validated as a result of the decode operation.

protected boolean

Returns:

true if the header values should be validated as a result of the decode operation.
validateHeaderValues
()

Determines if the header values should be validated as a result of the decode operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

headerArraySizeAccumulatorback to summary
private float headerArraySizeAccumulator

Used to calculate an exponential moving average of header sizes to get an estimate of how large the data structure for storing headers should be.

HEADERS_COUNT_WEIGHT_HISTORICALback to summary
private static final float HEADERS_COUNT_WEIGHT_HISTORICAL
HEADERS_COUNT_WEIGHT_NEWback to summary
private static final float HEADERS_COUNT_WEIGHT_NEW
hpackDecoderback to summary
private final HpackDecoder hpackDecoder
maxHeaderListSizeGoAwayback to summary
private long maxHeaderListSizeGoAway
validateHeadersback to summary
private final boolean validateHeaders
validateHeaderValuesback to summary
private final boolean validateHeaderValues

Constructor Detail

DefaultHttp2HeadersDecoderback to summary
public DefaultHttp2HeadersDecoder()
DefaultHttp2HeadersDecoderback to summary
public DefaultHttp2HeadersDecoder(boolean validateHeaders)

Create a new instance.

Parameters
validateHeaders:boolean

true to validate headers are valid according to the RFC.

DefaultHttp2HeadersDecoderback to summary
public DefaultHttp2HeadersDecoder(boolean validateHeaders, boolean validateHeaderValues)

Create a new instance.

Parameters
validateHeaders:boolean

true to validate headers are valid according to the RFC. This validates everything except header values.

validateHeaderValues:boolean

true to validate that header values are valid according to the RFC. Since this is potentially expensive, it can be enabled separately from validateHeaders.

DefaultHttp2HeadersDecoderback to summary
public DefaultHttp2HeadersDecoder(boolean validateHeaders, long maxHeaderListSize)

Create a new instance.

Parameters
validateHeaders:boolean

true to validate headers are valid according to the RFC.

maxHeaderListSize:long

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).

DefaultHttp2HeadersDecoderback to summary
public DefaultHttp2HeadersDecoder(boolean validateHeaders, boolean validateHeaderValues, long maxHeaderListSize)

Create a new instance.

Parameters
validateHeaders:boolean

true to validate headers are valid according to the RFC. This validates everything except header values.

validateHeaderValues:boolean

true to validate that header values are valid according to the RFC. Since this is potentially expensive, it can be enabled separately from validateHeaders.

maxHeaderListSize:long

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).

DefaultHttp2HeadersDecoderback to summary
pack-priv DefaultHttp2HeadersDecoder(boolean validateHeaders, boolean validateHeaderValues, HpackDecoder hpackDecoder)

Exposed 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

configurationback to summary
public Http2HeadersDecoder.Configuration configuration()

Implements io.netty5.handler.codec.http2.Http2HeadersDecoder.configuration.

Doc from io.netty5.handler.codec.http2.Http2HeadersDecoder.configuration.

Get the Configuration for this Http2HeadersDecoder

Annotations
@Override
decodeHeadersback to summary
public Http2Headers decodeHeaders(int streamId, Buffer headerBlock) throws Http2Exception

Implements io.netty5.handler.codec.http2.Http2HeadersDecoder.decodeHeaders.

Doc from io.netty5.handler.codec.http2.Http2HeadersDecoder.decodeHeaders.

Decodes the given headers block and returns the headers.

Annotations
@Override
maxHeaderListSizeback to summary
public void maxHeaderListSize(long max, long goAwayMax) throws Http2Exception

Implements io.netty5.handler.codec.http2.Http2HeadersDecoder.Configuration.maxHeaderListSize.

Doc from io.netty5.handler.codec.http2.Http2HeadersDecoder.Configuration.maxHeaderListSize.

Configure 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 SETTINGS frame.

Parameters
max:long

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 a RST_STREAM frame will be sent for the offending stream.

goAwayMax:long

Must be >= max. A GO_AWAY frame will be generated if this limit is exceeded for any particular stream.

Annotations
@Override
Exceptions
Http2Exception:
if limits exceed the RFC's boundaries or max > goAwayMax.
maxHeaderListSizeback to summary
public long maxHeaderListSize()

Implements io.netty5.handler.codec.http2.Http2HeadersDecoder.Configuration.maxHeaderListSize.

Doc from io.netty5.handler.codec.http2.Http2HeadersDecoder.Configuration.maxHeaderListSize.

Represents the value for SETTINGS_MAX_HEADER_LIST_SIZE.

Annotations
@Override
maxHeaderListSizeGoAwayback to summary
public long maxHeaderListSizeGoAway()

Implements io.netty5.handler.codec.http2.Http2HeadersDecoder.Configuration.maxHeaderListSizeGoAway.

Doc from io.netty5.handler.codec.http2.Http2HeadersDecoder.Configuration.maxHeaderListSizeGoAway.

Represents the upper bound in bytes for a set of headers before a GO_AWAY should be sent. This will be <= SETTINGS_MAX_HEADER_LIST_SIZE.

Annotations
@Override
maxHeaderTableSizeback to summary
public void maxHeaderTableSize(long max) throws Http2Exception

Implements io.netty5.handler.codec.http2.Http2HeadersDecoder.Configuration.maxHeaderTableSize.

Doc from io.netty5.handler.codec.http2.Http2HeadersDecoder.Configuration.maxHeaderTableSize.

Represents the value for SETTINGS_HEADER_TABLE_SIZE. This method should only be called by Netty (not users) as a result of a receiving a SETTINGS frame.

Annotations
@Override
maxHeaderTableSizeback to summary
public long maxHeaderTableSize()

Implements io.netty5.handler.codec.http2.Http2HeadersDecoder.Configuration.maxHeaderTableSize.

Doc from io.netty5.handler.codec.http2.Http2HeadersDecoder.Configuration.maxHeaderTableSize.

Represents the value for SETTINGS_HEADER_TABLE_SIZE. The initial value returned by this method must be Http2CodecUtil#DEFAULT_HEADER_TABLE_SIZE.

Annotations
@Override
newHeadersback to summary
protected Http2Headers newHeaders()

Create a new Http2Headers object which will store the results of the decode operation.

Returns:Http2Headers

a new Http2Headers object which will store the results of the decode operation.

numberOfHeadersGuessback to summary
protected final int numberOfHeadersGuess()

A weighted moving average estimating how many headers are expected during the decode process.

Returns:int

an estimate of how many headers are expected during the decode process.

validateHeadersback to summary
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:boolean

true if the headers should be validated as a result of the decode operation.

validateHeaderValuesback to summary
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:boolean

true if the header values should be validated as a result of the decode operation.