Top Description Fields Constructors Methods
io.netty.handler.codec.http2

public abstract Class AbstractHttp2ConnectionHandlerBuilder<T extends io.netty.handler.codec.http2.Http2ConnectionHandler, B extends io.netty.handler.codec.http2.AbstractHttp2ConnectionHandlerBuilder<T, B>>

extends Object
Class Inheritance
Known Direct Subclasses
io.netty.handler.codec.http2.Http2MultiplexCodecBuilder, io.netty.handler.codec.http2.Http2ConnectionHandlerBuilder, io.netty.handler.codec.http2.Http2FrameCodecBuilder, io.netty.handler.codec.http2.HttpToHttp2ConnectionHandlerBuilder
Annotations
@UnstableApi
Type Parameters
<T>
The type of handler created by this builder.
<B>
The concrete type of this builder.
Imports
io.netty.channel.Channel, io.netty.handler.codec.http2.Http2HeadersEncoder.SensitivityDetector, io.netty.util.internal.UnstableApi

Abstract base class which defines commonly used features required to build Http2ConnectionHandler instances.

Three ways to build a Http2ConnectionHandler

Let the builder create a Http2ConnectionHandler

Simply call all the necessary setter methods, and then use build() to build a new Http2ConnectionHandler. Setting the following properties are prohibited because they are used for other ways of building a Http2ConnectionHandler. conflicts with this option:

Let the builder use the Http2ConnectionHandler you specified

Call connection(Http2Connection) to tell the builder that you want to build the handler from the Http2Connection you specified. Setting the following properties are prohibited and thus will trigger an IllegalStateException because they conflict with this option.

Let the builder use the Http2ConnectionDecoder and Http2ConnectionEncoder you specified

Call codec(Http2ConnectionDecoder, Http2ConnectionEncoder) to tell the builder that you want to built the handler from the Http2ConnectionDecoder and Http2ConnectionEncoder you specified. Setting the following properties are prohibited and thus will trigger an IllegalStateException because they conflict with this option:

Exposing necessary methods in a subclass

build() method and all property access methods are protected. Choose the methods to expose to the users of your builder implementation and make them public.

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private Http2Connection
private Http2ConnectionDecoder
private boolean
private static final Http2HeadersEncoder.SensitivityDetector
private static final int
private Http2ConnectionEncoder
private Boolean
private Boolean
private boolean
private Http2FrameListener
private Http2FrameLogger
private long
private Http2HeadersEncoder.SensitivityDetector
private Http2Settings
private Boolean
private int
private int
private Integer
private Integer
private Http2PromisedRequestVerifier
private int
private Boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected B

Returns:

this.
autoAckPingFrame
(boolean autoAckPingFrame)

Determine if PING frame should automatically be acknowledged or not.

protected B

Returns:

this.
autoAckSettingsFrame
(boolean autoAckSettings)

Determine if settings frame should automatically be acknowledged and applied.

protected T
protected abstract T
build(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings)

Implement this method to create a new Http2ConnectionHandler or its subtype instance.

private T
private T
protected B
protected Http2Connection

Returns:

Http2Connection if set, or null if not set.
connection
()

Returns the Http2Connection to use.

protected B
connection(Http2Connection connection)

Sets the Http2Connection to use.

protected Http2ConnectionDecoder

Returns:

Http2ConnectionDecoder if set, or null if not set.
decoder
()

Returns the Http2ConnectionDecoder to use.

protected int
decoderEnforceMaxConsecutiveEmptyDataFrames()

Returns the maximum number of consecutive empty DATA frames (without end_of_stream flag) that are allowed before the connection is closed.

protected B
decoderEnforceMaxConsecutiveEmptyDataFrames(int maxConsecutiveEmptyFrames)

Sets the maximum number of consecutive empty DATA frames (without end_of_stream flag) that are allowed before the connection is closed.

protected B
decoderEnforceMaxRstFramesPerWindow(int maxRstFramesPerWindow, int secondsPerWindow)

Sets the maximum number RST frames that are allowed per window before the connection is closed.

protected B

Returns:

this.
decoupleCloseAndGoAway
(boolean
true to make Channel#close() directly close the underlying transport, and not attempt graceful closure via GOAWAY.
decoupleCloseAndGoAway
)

Determine if the Channel#close() should be coupled with goaway and graceful close.

protected boolean
decoupleCloseAndGoAway()

Determine if the Channel#close() should be coupled with goaway and graceful close.

protected Http2ConnectionEncoder

Returns:

Http2ConnectionEncoder if set, or null if not set.
encoder
()

Returns the Http2ConnectionEncoder to use.

protected boolean
encoderEnforceMaxConcurrentStreams()

Returns if the encoder should queue frames if the maximum number of concurrent streams would otherwise be exceeded.

protected B
encoderEnforceMaxConcurrentStreams(boolean encoderEnforceMaxConcurrentStreams)

Sets if the encoder should queue frames if the maximum number of concurrent streams would otherwise be exceeded.

protected int
encoderEnforceMaxQueuedControlFrames()

Returns the maximum number of queued control frames that are allowed before the connection is closed.

protected B
encoderEnforceMaxQueuedControlFrames(int maxQueuedControlFrames)

Sets the maximum number of queued control frames that are allowed before the connection is closed.

protected B

Returns:

this.
encoderIgnoreMaxHeaderListSize
(boolean ignoreMaxHeaderListSize)

Sets if the SETTINGS_MAX_HEADER_LIST_SIZE should be ignored when encoding headers.

private static void
enforceConstraint(String methodName, String rejectorName, Object value)

private void
protected B

Returns:

this.
flushPreface
(boolean
true to automatically flush, false otherwise.
flushPreface
)

Determine if the Preface should be automatically flushed when the Channel becomes active or not.

protected boolean

Returns:

true if automatically flushed.
flushPreface
()

Determine if the Preface should be automatically flushed when the Channel becomes active or not.

protected Http2FrameListener

Returns:

Http2FrameListener if set, or null if not set.
frameListener
()

Returns the listener of inbound frames.

protected B
frameListener(Http2FrameListener frameListener)

Sets the listener of inbound frames.

protected Http2FrameLogger

Returns:

Http2FrameLogger if set, or null if not set.
frameLogger
()

Returns the logger that is used for the encoder and decoder.

protected B
frameLogger(Http2FrameLogger frameLogger)

Sets the logger that is used for the encoder and decoder.

protected long
gracefulShutdownTimeoutMillis()

Returns the graceful shutdown timeout of the Http2Connection in milliseconds.

protected B
gracefulShutdownTimeoutMillis(long gracefulShutdownTimeoutMillis)

Sets the graceful shutdown timeout of the Http2Connection in milliseconds.

protected Http2HeadersEncoder.SensitivityDetector
protected B
protected B
initialHuffmanDecodeCapacity(int initialHuffmanDecodeCapacity)

Deprecated Huffman decoding no longer depends on having a decode capacity.
Does nothing, do not call.
protected Http2Settings
initialSettings()

Sets the Http2Settings to use for the initial connection settings exchange.

protected B
initialSettings(Http2Settings settings)

Sets the Http2Settings to use for the initial connection settings exchange.

protected boolean

Returns:

true if the PING frames should be automatically acknowledged.
isAutoAckPingFrame
()

Determine if the PING frames should be automatically acknowledged or not.

protected boolean

Returns:

true if the SETTINGS frames should be automatically acknowledged and applied.
isAutoAckSettingsFrame
()

Determine if the SETTINGS frames should be automatically acknowledged and applied.

protected boolean
isServer()

Returns if build() will to create a Http2Connection in server mode (true) or client mode (false).

protected boolean
isValidateHeaders()

Returns if HTTP headers should be validated according to RFC 7540, 8.1.2.6.

protected int
maxReservedStreams()

Get the maximum number of streams which can be in the reserved state at any given time.

protected B
maxReservedStreams(int maxReservedStreams)

Set the maximum number of streams which can be in the reserved state at any given time.

protected B

Returns:

this.
promisedRequestVerifier
(Http2PromisedRequestVerifier promisedRequestVerifier)

Set the Http2PromisedRequestVerifier to use.

protected Http2PromisedRequestVerifier
protected final B
self()

Returns this.

protected B
server(boolean isServer)

Sets if build() will to create a Http2Connection in server mode (true) or client mode (false).

protected B
validateHeaders(boolean validateHeaders)

Sets if HTTP headers should be validated according to RFC 7540, 8.1.2.6.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

autoAckPingFrameback to summary
private boolean autoAckPingFrame
autoAckSettingsFrameback to summary
private boolean autoAckSettingsFrame
connectionback to summary
private Http2Connection connection
decoderback to summary
private Http2ConnectionDecoder decoder
decoupleCloseAndGoAwayback to summary
private boolean decoupleCloseAndGoAway
DEFAULT_HEADER_SENSITIVITY_DETECTORback to summary
private static final Http2HeadersEncoder.SensitivityDetector DEFAULT_HEADER_SENSITIVITY_DETECTOR
DEFAULT_MAX_RST_FRAMES_PER_CONNECTION_FOR_SERVERback to summary
private static final int DEFAULT_MAX_RST_FRAMES_PER_CONNECTION_FOR_SERVER
encoderback to summary
private Http2ConnectionEncoder encoder
encoderEnforceMaxConcurrentStreamsback to summary
private Boolean encoderEnforceMaxConcurrentStreams
encoderIgnoreMaxHeaderListSizeback to summary
private Boolean encoderIgnoreMaxHeaderListSize
flushPrefaceback to summary
private boolean flushPreface
frameListenerback to summary
private Http2FrameListener frameListener
frameLoggerback to summary
private Http2FrameLogger frameLogger
gracefulShutdownTimeoutMillisback to summary
private long gracefulShutdownTimeoutMillis
headerSensitivityDetectorback to summary
private Http2HeadersEncoder.SensitivityDetector headerSensitivityDetector
initialSettingsback to summary
private Http2Settings initialSettings
isServerback to summary
private Boolean isServer
maxConsecutiveEmptyFramesback to summary
private int maxConsecutiveEmptyFrames
maxQueuedControlFramesback to summary
private int maxQueuedControlFrames
maxReservedStreamsback to summary
private Integer maxReservedStreams
maxRstFramesPerWindowback to summary
private Integer maxRstFramesPerWindow
promisedRequestVerifierback to summary
private Http2PromisedRequestVerifier promisedRequestVerifier
secondsPerWindowback to summary
private int secondsPerWindow
validateHeadersback to summary
private Boolean validateHeaders

Constructor Detail

AbstractHttp2ConnectionHandlerBuilderback to summary
public AbstractHttp2ConnectionHandlerBuilder()

Method Detail

autoAckPingFrameback to summary
protected B autoAckPingFrame(boolean autoAckPingFrame)

Determine if PING frame should automatically be acknowledged or not.

Returns:B

this.

autoAckSettingsFrameback to summary
protected B autoAckSettingsFrame(boolean autoAckSettings)

Determine if settings frame should automatically be acknowledged and applied.

Returns:B

this.

buildback to summary
protected T build()

Create a new Http2ConnectionHandler.

buildback to summary
protected abstract T build(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings) throws Exception

Implement this method to create a new Http2ConnectionHandler or its subtype instance.

The return of this method will be subject to the following:

buildFromCodecback to summary
private T buildFromCodec(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder)
buildFromConnectionback to summary
private T buildFromConnection(Http2Connection connection)
codecback to summary
protected B codec(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder)

Sets the Http2ConnectionDecoder and Http2ConnectionEncoder to use.

connectionback to summary
protected Http2Connection connection()

Returns the Http2Connection to use.

Returns:Http2Connection

Http2Connection if set, or null if not set.

connectionback to summary
protected B connection(Http2Connection connection)

Sets the Http2Connection to use.

decoderback to summary
protected Http2ConnectionDecoder decoder()

Returns the Http2ConnectionDecoder to use.

Returns:Http2ConnectionDecoder

Http2ConnectionDecoder if set, or null if not set.

decoderEnforceMaxConsecutiveEmptyDataFramesback to summary
protected int decoderEnforceMaxConsecutiveEmptyDataFrames()

Returns the maximum number of consecutive empty DATA frames (without end_of_stream flag) that are allowed before the connection is closed. This allows to protect against the remote peer flooding us with such frames and so use up a lot of CPU. There is no valid use-case for empty DATA frames without end_of_stream flag. 0 means no protection is in place.

decoderEnforceMaxConsecutiveEmptyDataFramesback to summary
protected B decoderEnforceMaxConsecutiveEmptyDataFrames(int maxConsecutiveEmptyFrames)

Sets the maximum number of consecutive empty DATA frames (without end_of_stream flag) that are allowed before the connection is closed. This allows to protect against the remote peer flooding us with such frames and so use up a lot of CPU. There is no valid use-case for empty DATA frames without end_of_stream flag. 0 means no protection should be applied.

decoderEnforceMaxRstFramesPerWindowback to summary
protected B decoderEnforceMaxRstFramesPerWindow(int maxRstFramesPerWindow, int secondsPerWindow)

Sets the maximum number RST frames that are allowed per window before the connection is closed. This allows to protect against the remote peer flooding us with such frames and so use up a lot of CPU. 0 for any of the parameters means no protection should be applied.

decoupleCloseAndGoAwayback to summary
protected B decoupleCloseAndGoAway(boolean decoupleCloseAndGoAway)

Determine if the Channel#close() should be coupled with goaway and graceful close.

Parameters
decoupleCloseAndGoAway:boolean

true to make Channel#close() directly close the underlying transport, and not attempt graceful closure via GOAWAY.

Returns:B

this.

decoupleCloseAndGoAwayback to summary
protected boolean decoupleCloseAndGoAway()

Determine if the Channel#close() should be coupled with goaway and graceful close.

encoderback to summary
protected Http2ConnectionEncoder encoder()

Returns the Http2ConnectionEncoder to use.

Returns:Http2ConnectionEncoder

Http2ConnectionEncoder if set, or null if not set.

encoderEnforceMaxConcurrentStreamsback to summary
protected boolean encoderEnforceMaxConcurrentStreams()

Returns if the encoder should queue frames if the maximum number of concurrent streams would otherwise be exceeded.

encoderEnforceMaxConcurrentStreamsback to summary
protected B encoderEnforceMaxConcurrentStreams(boolean encoderEnforceMaxConcurrentStreams)

Sets if the encoder should queue frames if the maximum number of concurrent streams would otherwise be exceeded.

encoderEnforceMaxQueuedControlFramesback to summary
protected int encoderEnforceMaxQueuedControlFrames()

Returns the maximum number of queued control frames that are allowed before the connection is closed. This allows to protected against various attacks that can lead to high CPU / memory usage if the remote-peer floods us with frames that would have us produce control frames, but stops to read from the underlying socket. 0 means no protection is in place.

encoderEnforceMaxQueuedControlFramesback to summary
protected B encoderEnforceMaxQueuedControlFrames(int maxQueuedControlFrames)

Sets the maximum number of queued control frames that are allowed before the connection is closed. This allows to protected against various attacks that can lead to high CPU / memory usage if the remote-peer floods us with frames that would have us produce control frames, but stops to read from the underlying socket. 0 means no protection should be applied.

encoderIgnoreMaxHeaderListSizeback to summary
protected B encoderIgnoreMaxHeaderListSize(boolean ignoreMaxHeaderListSize)

Sets if the SETTINGS_MAX_HEADER_LIST_SIZE should be ignored when encoding headers.

Parameters
ignoreMaxHeaderListSize:boolean

true to ignore SETTINGS_MAX_HEADER_LIST_SIZE.

Returns:B

this.

enforceConstraintback to summary
private static void enforceConstraint(String methodName, String rejectorName, Object value)
enforceNonCodecConstraintsback to summary
private void enforceNonCodecConstraints(String rejected)
flushPrefaceback to summary
protected B flushPreface(boolean flushPreface)

Determine if the Preface should be automatically flushed when the Channel becomes active or not.

Client may choose to opt-out from this automatic behavior and manage flush manually if it's ready to send request frames immediately after the preface. It may help to avoid unnecessary latency.

Parameters
flushPreface:boolean

true to automatically flush, false otherwise.

Returns:B

this.

See Also
HTTP/2 Connection Preface
flushPrefaceback to summary
protected boolean flushPreface()

Determine if the Preface should be automatically flushed when the Channel becomes active or not.

Client may choose to opt-out from this automatic behavior and manage flush manually if it's ready to send request frames immediately after the preface. It may help to avoid unnecessary latency.

Returns:boolean

true if automatically flushed.

See Also
HTTP/2 Connection Preface
frameListenerback to summary
protected Http2FrameListener frameListener()

Returns the listener of inbound frames.

Returns:Http2FrameListener

Http2FrameListener if set, or null if not set.

frameListenerback to summary
protected B frameListener(Http2FrameListener frameListener)

Sets the listener of inbound frames. This listener will only be set if the decoder's listener is null.

frameLoggerback to summary
protected Http2FrameLogger frameLogger()

Returns the logger that is used for the encoder and decoder.

Returns:Http2FrameLogger

Http2FrameLogger if set, or null if not set.

frameLoggerback to summary
protected B frameLogger(Http2FrameLogger frameLogger)

Sets the logger that is used for the encoder and decoder.

gracefulShutdownTimeoutMillisback to summary
protected long gracefulShutdownTimeoutMillis()

Returns the graceful shutdown timeout of the Http2Connection in milliseconds. Returns -1 if the timeout is indefinite.

gracefulShutdownTimeoutMillisback to summary
protected B gracefulShutdownTimeoutMillis(long gracefulShutdownTimeoutMillis)

Sets the graceful shutdown timeout of the Http2Connection in milliseconds.

headerSensitivityDetectorback to summary
protected Http2HeadersEncoder.SensitivityDetector headerSensitivityDetector()

Returns the SensitivityDetector to use.

headerSensitivityDetectorback to summary
protected B headerSensitivityDetector(Http2HeadersEncoder.SensitivityDetector headerSensitivityDetector)

Sets the SensitivityDetector to use.

initialHuffmanDecodeCapacityback to summary
protected B initialHuffmanDecodeCapacity(int initialHuffmanDecodeCapacity)

Deprecated

Huffman decoding no longer depends on having a decode capacity.

Does nothing, do not call.

Annotations
@Deprecated
initialSettingsback to summary
protected Http2Settings initialSettings()

Sets the Http2Settings to use for the initial connection settings exchange.

initialSettingsback to summary
protected B initialSettings(Http2Settings settings)

Sets the Http2Settings to use for the initial connection settings exchange.

isAutoAckPingFrameback to summary
protected boolean isAutoAckPingFrame()

Determine if the PING frames should be automatically acknowledged or not.

Returns:boolean

true if the PING frames should be automatically acknowledged.

isAutoAckSettingsFrameback to summary
protected boolean isAutoAckSettingsFrame()

Determine if the SETTINGS frames should be automatically acknowledged and applied.

Returns:boolean

true if the SETTINGS frames should be automatically acknowledged and applied.

isServerback to summary
protected boolean isServer()

Returns if build() will to create a Http2Connection in server mode (true) or client mode (false).

isValidateHeadersback to summary
protected boolean isValidateHeaders()

Returns if HTTP headers should be validated according to RFC 7540, 8.1.2.6.

maxReservedStreamsback to summary
protected int maxReservedStreams()

Get the maximum number of streams which can be in the reserved state at any given time.

By default this value will be ignored on the server for local endpoint. This is because the RFC provides no way to explicitly communicate a limit to how many states can be in the reserved state, and instead relies on the peer to send RST_STREAM frames when they will be rejected.

maxReservedStreamsback to summary
protected B maxReservedStreams(int maxReservedStreams)

Set the maximum number of streams which can be in the reserved state at any given time.

promisedRequestVerifierback to summary
protected B promisedRequestVerifier(Http2PromisedRequestVerifier promisedRequestVerifier)

Set the Http2PromisedRequestVerifier to use.

Returns:B

this.

promisedRequestVerifierback to summary
protected Http2PromisedRequestVerifier promisedRequestVerifier()

Get the Http2PromisedRequestVerifier to use.

Returns:Http2PromisedRequestVerifier

the Http2PromisedRequestVerifier to use.

selfback to summary
protected final B self()

Returns this.

Annotations
@SuppressWarnings:unchecked
serverback to summary
protected B server(boolean isServer)

Sets if build() will to create a Http2Connection in server mode (true) or client mode (false).

validateHeadersback to summary
protected B validateHeaders(boolean validateHeaders)

Sets if HTTP headers should be validated according to RFC 7540, 8.1.2.6.