Class AbstractHttp2ConnectionHandlerBuilder<T extends Http2ConnectionHandler, B extends AbstractHttp2ConnectionHandlerBuilder<T,B>>
java.lang.Object
io.netty.handler.codec.http2.AbstractHttp2ConnectionHandlerBuilder<T,B>
- Type Parameters:
T- The type of handler created by this builder.B- The concrete type of this builder.
- Direct Known Subclasses:
Http2ConnectionHandlerBuilder, Http2FrameCodecBuilder, Http2MultiplexCodecBuilder, HttpToHttp2ConnectionHandlerBuilder
public abstract class AbstractHttp2ConnectionHandlerBuilder<T extends Http2ConnectionHandler, B extends AbstractHttp2ConnectionHandlerBuilder<T,B>>
extends Object
Abstract base class which defines commonly used features required to build Three ways to build a
Let the builder create a
Simply call all the necessary setter methods, and then use Let the builder use the
Call Let the builder use the
Call
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:
server(boolean)connection(Http2Connection)frameLogger(Http2FrameLogger)headerSensitivityDetector(SensitivityDetector)encoderEnforceMaxConcurrentStreams(boolean)encoderIgnoreMaxHeaderListSize(boolean)
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.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected BautoAckPingFrame(boolean autoAckPingFrame) Determine if PING frame should automatically be acknowledged or not.protected BautoAckSettingsFrame(boolean autoAckSettings) Determine if settings frame should automatically be acknowledged and applied.protected Tbuild()Create a newHttp2ConnectionHandler.protected abstract Tbuild(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings) Implement this method to create a newHttp2ConnectionHandleror its subtype instance.protected Bcodec(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder) Sets theHttp2ConnectionDecoderandHttp2ConnectionEncoderto use.protected Http2ConnectionReturns theHttp2Connectionto use.protected Bconnection(Http2Connection connection) Sets theHttp2Connectionto use.protected Http2ConnectionDecoderdecoder()Returns theHttp2ConnectionDecoderto use.protected intReturns the maximum number of consecutive empty DATA frames (without end_of_stream flag) that are allowed before the connection is closed.protected BdecoderEnforceMaxConsecutiveEmptyDataFrames(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 BdecoderEnforceMaxRstFramesPerWindow(int maxRstFramesPerWindow, int secondsPerWindow) Sets the maximum number RST frames that are allowed per window before the connection is closed.protected booleanDetermine if theChannel.close()should be coupled with goaway and graceful close.protected BdecoupleCloseAndGoAway(boolean decoupleCloseAndGoAway) Determine if theChannel.close()should be coupled with goaway and graceful close.protected Http2ConnectionEncoderencoder()Returns theHttp2ConnectionEncoderto use.protected booleanReturns if the encoder should queue frames if the maximum number of concurrent streams would otherwise be exceeded.protected BencoderEnforceMaxConcurrentStreams(boolean encoderEnforceMaxConcurrentStreams) Sets if the encoder should queue frames if the maximum number of concurrent streams would otherwise be exceeded.protected intReturns the maximum number of queued control frames that are allowed before the connection is closed.protected BencoderEnforceMaxQueuedControlFrames(int maxQueuedControlFrames) Sets the maximum number of queued control frames that are allowed before the connection is closed.protected BencoderEnforceMaxRstFramesPerWindow(int maxRstFramesPerWindow, int secondsPerWindow) Sets the maximum number RST frames that are allowed per window before the connection is closed.protected BencoderIgnoreMaxHeaderListSize(boolean ignoreMaxHeaderListSize) Sets if the SETTINGS_MAX_HEADER_LIST_SIZE should be ignored when encoding headers.protected booleanprotected BflushPreface(boolean flushPreface) protected Http2FrameListenerReturns the listener of inbound frames.protected BframeListener(Http2FrameListener frameListener) Sets the listener of inbound frames.protected Http2FrameLoggerReturns the logger that is used for the encoder and decoder.protected BframeLogger(Http2FrameLogger frameLogger) Sets the logger that is used for the encoder and decoder.protected longReturns the graceful shutdown timeout of theHttp2Connectionin milliseconds.protected BgracefulShutdownTimeoutMillis(long gracefulShutdownTimeoutMillis) Sets the graceful shutdown timeout of theHttp2Connectionin milliseconds.protected Http2HeadersEncoder.SensitivityDetectorReturns theHttp2HeadersEncoder.SensitivityDetectorto use.protected BheaderSensitivityDetector(Http2HeadersEncoder.SensitivityDetector headerSensitivityDetector) Sets theHttp2HeadersEncoder.SensitivityDetectorto use.protected BinitialHuffmanDecodeCapacity(int initialHuffmanDecodeCapacity) Deprecated.Huffman decoding no longer depends on having a decode capacity.protected Http2SettingsSets theHttp2Settingsto use for the initial connection settings exchange.protected BinitialSettings(Http2Settings settings) Sets theHttp2Settingsto use for the initial connection settings exchange.protected booleanDetermine if the PING frames should be automatically acknowledged or not.protected booleanDetermine if the SETTINGS frames should be automatically acknowledged and applied.protected booleanisServer()protected booleanReturns if HTTP headers should be validated according to RFC 7540, 8.1.2.6.protected intGet the maximum number of streams which can be in the reserved state at any given time.protected BmaxReservedStreams(int maxReservedStreams) Set the maximum number of streams which can be in the reserved state at any given time.protected Http2PromisedRequestVerifierGet theHttp2PromisedRequestVerifierto use.protected BpromisedRequestVerifier(Http2PromisedRequestVerifier promisedRequestVerifier) Set theHttp2PromisedRequestVerifierto use.protected final Bself()Returnsthis.protected Bserver(boolean isServer) protected BvalidateHeaders(boolean validateHeaders) Sets if HTTP headers should be validated according to RFC 7540, 8.1.2.6.
-
Constructor Details
-
AbstractHttp2ConnectionHandlerBuilder
public AbstractHttp2ConnectionHandlerBuilder()
-
-
Method Details
-
initialSettings
Sets theHttp2Settingsto use for the initial connection settings exchange. -
initialSettings
Sets theHttp2Settingsto use for the initial connection settings exchange. -
frameListener
Returns the listener of inbound frames.- Returns:
Http2FrameListenerif set, ornullif not set.
-
frameListener
Sets the listener of inbound frames. This listener will only be set if the decoder's listener isnull. -
gracefulShutdownTimeoutMillis
protected long gracefulShutdownTimeoutMillis()Returns the graceful shutdown timeout of theHttp2Connectionin milliseconds. Returns -1 if the timeout is indefinite. -
gracefulShutdownTimeoutMillis
Sets the graceful shutdown timeout of theHttp2Connectionin milliseconds. -
isServer
protected boolean isServer() -
server
-
maxReservedStreams
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.
-
maxReservedStreams
Set the maximum number of streams which can be in the reserved state at any given time. -
connection
Returns theHttp2Connectionto use.- Returns:
Http2Connectionif set, ornullif not set.
-
connection
Sets theHttp2Connectionto use. -
decoder
Returns theHttp2ConnectionDecoderto use.- Returns:
Http2ConnectionDecoderif set, ornullif not set.
-
encoder
Returns theHttp2ConnectionEncoderto use.- Returns:
Http2ConnectionEncoderif set, ornullif not set.
-
codec
Sets theHttp2ConnectionDecoderandHttp2ConnectionEncoderto use. -
isValidateHeaders
protected boolean isValidateHeaders()Returns if HTTP headers should be validated according to RFC 7540, 8.1.2.6. -
validateHeaders
Sets if HTTP headers should be validated according to RFC 7540, 8.1.2.6. -
frameLogger
Returns the logger that is used for the encoder and decoder.- Returns:
Http2FrameLoggerif set, ornullif not set.
-
frameLogger
Sets the logger that is used for the encoder and decoder. -
encoderEnforceMaxConcurrentStreams
protected boolean encoderEnforceMaxConcurrentStreams()Returns if the encoder should queue frames if the maximum number of concurrent streams would otherwise be exceeded. -
encoderEnforceMaxConcurrentStreams
Sets if the encoder should queue frames if the maximum number of concurrent streams would otherwise be exceeded. -
encoderEnforceMaxQueuedControlFrames
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.0means no protection is in place. -
encoderEnforceMaxQueuedControlFrames
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.0means no protection should be applied. -
headerSensitivityDetector
Returns theHttp2HeadersEncoder.SensitivityDetectorto use. -
headerSensitivityDetector
protected B headerSensitivityDetector(Http2HeadersEncoder.SensitivityDetector headerSensitivityDetector) Sets theHttp2HeadersEncoder.SensitivityDetectorto use. -
encoderIgnoreMaxHeaderListSize
Sets if the SETTINGS_MAX_HEADER_LIST_SIZE should be ignored when encoding headers.- Parameters:
ignoreMaxHeaderListSize-trueto ignore SETTINGS_MAX_HEADER_LIST_SIZE.- Returns:
- this.
-
initialHuffmanDecodeCapacity
Deprecated.Huffman decoding no longer depends on having a decode capacity.Does nothing, do not call. -
promisedRequestVerifier
Set theHttp2PromisedRequestVerifierto use.- Returns:
- this.
-
promisedRequestVerifier
Get theHttp2PromisedRequestVerifierto use.- Returns:
- the
Http2PromisedRequestVerifierto use.
-
decoderEnforceMaxConsecutiveEmptyDataFrames
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.0means no protection is in place. -
decoderEnforceMaxConsecutiveEmptyDataFrames
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.0means no protection should be applied. -
decoderEnforceMaxRstFramesPerWindow
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.0for any of the parameters means no protection should be applied. -
encoderEnforceMaxRstFramesPerWindow
Sets the maximum number RST frames that are allowed per window before the connection is closed. This allows to protect against the remote peer that will trigger us to generate a flood of RST frames and so use up a lot of CPU.0for any of the parameters means no protection should be applied. -
autoAckSettingsFrame
Determine if settings frame should automatically be acknowledged and applied.- Returns:
- this.
-
isAutoAckSettingsFrame
protected boolean isAutoAckSettingsFrame()Determine if the SETTINGS frames should be automatically acknowledged and applied.- Returns:
trueif the SETTINGS frames should be automatically acknowledged and applied.
-
autoAckPingFrame
Determine if PING frame should automatically be acknowledged or not.- Returns:
- this.
-
isAutoAckPingFrame
protected boolean isAutoAckPingFrame()Determine if the PING frames should be automatically acknowledged or not.- Returns:
trueif the PING frames should be automatically acknowledged.
-
decoupleCloseAndGoAway
Determine if theChannel.close()should be coupled with goaway and graceful close.- Parameters:
decoupleCloseAndGoAway-trueto makeChannel.close()directly close the underlying transport, and not attempt graceful closure via GOAWAY.- Returns:
this.
-
decoupleCloseAndGoAway
protected boolean decoupleCloseAndGoAway()Determine if theChannel.close()should be coupled with goaway and graceful close. -
flushPreface
Determine if the Preface should be automatically flushed when theChannelbecomes 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-trueto automatically flush,false otherwise.- Returns:
this.- See Also:
-
flushPreface
protected boolean flushPreface()Determine if the Preface should be automatically flushed when theChannelbecomes 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:
trueif automatically flushed.- See Also:
-
build
Create a newHttp2ConnectionHandler. -
build
protected abstract T build(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings) throws Exception Implement this method to create a newHttp2ConnectionHandleror its subtype instance.The return of this method will be subject to the following:
frameListener(Http2FrameListener)will be set if not already set in the decodergracefulShutdownTimeoutMillis(long)will always be set
- Throws:
Exception
-
self
Returnsthis.
-