Module io.netty.codec.http2
Package io.netty5.handler.codec.http2
Class AbstractHttp2ConnectionHandlerBuilder<T extends Http2ConnectionHandler,B extends AbstractHttp2ConnectionHandlerBuilder<T,B>>
- java.lang.Object
-
- io.netty5.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
,HttpToHttp2ConnectionHandlerBuilder
@UnstableApi public abstract class AbstractHttp2ConnectionHandlerBuilder<T extends Http2ConnectionHandler,B extends AbstractHttp2ConnectionHandlerBuilder<T,B>> extends Object
Abstract base class which defines commonly used features required to buildHttp2ConnectionHandler
instances.Three ways to build a
Http2ConnectionHandler
Let the builder create a
Simply call all the necessary setter methods, and then useHttp2ConnectionHandler
build()
to build a newHttp2ConnectionHandler
. Setting the following properties are prohibited because they are used for other ways of building aHttp2ConnectionHandler
. conflicts with this option:Let the builder use the
CallHttp2ConnectionHandler
you specifiedconnection(Http2Connection)
to tell the builder that you want to build the handler from theHttp2Connection
you specified. Setting the following properties are prohibited and thus will trigger anIllegalStateException
because they conflict with this option.Let the builder use the
CallHttp2ConnectionDecoder
andHttp2ConnectionEncoder
you specifiedcodec(Http2ConnectionDecoder, Http2ConnectionEncoder)
to tell the builder that you want to built the handler from theHttp2ConnectionDecoder
andHttp2ConnectionEncoder
you specified. Setting the following properties are prohibited and thus will trigger anIllegalStateException
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 areprotected
. Choose the methods to expose to the users of your builder implementation and make thempublic
.
-
-
Constructor Summary
Constructors Constructor Description AbstractHttp2ConnectionHandlerBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected B
autoAckPingFrame(boolean autoAckPingFrame)
Determine if PING frame should automatically be acknowledged or not.protected B
autoAckSettingsFrame(boolean autoAckSettings)
Determine if settings frame should automatically be acknowledged and applied.protected T
build()
Create a newHttp2ConnectionHandler
.protected abstract T
build(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings)
Implement this method to create a newHttp2ConnectionHandler
or its subtype instance.protected B
codec(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder)
Sets theHttp2ConnectionDecoder
andHttp2ConnectionEncoder
to use.protected Http2Connection
connection()
Returns theHttp2Connection
to use.protected B
connection(Http2Connection connection)
Sets theHttp2Connection
to use.protected Http2ConnectionDecoder
decoder()
Returns theHttp2ConnectionDecoder
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 boolean
decoupleCloseAndGoAway()
Determine if theChannel.close()
should be coupled with goaway and graceful close.protected B
decoupleCloseAndGoAway(boolean decoupleCloseAndGoAway)
Determine if theChannel.close()
should be coupled with goaway and graceful close.protected Http2ConnectionEncoder
encoder()
Returns theHttp2ConnectionEncoder
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
encoderIgnoreMaxHeaderListSize(boolean ignoreMaxHeaderListSize)
Sets if the SETTINGS_MAX_HEADER_LIST_SIZE should be ignored when encoding headers.protected boolean
flushPreface()
protected B
flushPreface(boolean flushPreface)
protected Http2FrameListener
frameListener()
Returns the listener of inbound frames.protected B
frameListener(Http2FrameListener frameListener)
Sets the listener of inbound frames.protected Http2FrameLogger
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 theHttp2Connection
in milliseconds.protected B
gracefulShutdownTimeoutMillis(long gracefulShutdownTimeoutMillis)
Sets the graceful shutdown timeout of theHttp2Connection
in milliseconds.protected Http2HeadersEncoder.SensitivityDetector
headerSensitivityDetector()
Returns theHttp2HeadersEncoder.SensitivityDetector
to use.protected B
headerSensitivityDetector(Http2HeadersEncoder.SensitivityDetector headerSensitivityDetector)
Sets theHttp2HeadersEncoder.SensitivityDetector
to use.protected B
initialHuffmanDecodeCapacity(int initialHuffmanDecodeCapacity)
Deprecated.Huffman decoding no longer depends on having a decode capacity.protected Http2Settings
initialSettings()
Sets theHttp2Settings
to use for the initial connection settings exchange.protected B
initialSettings(Http2Settings settings)
Sets theHttp2Settings
to use for the initial connection settings exchange.protected boolean
isAutoAckPingFrame()
Determine if the PING frames should be automatically acknowledged or not.protected boolean
isAutoAckSettingsFrame()
Determine if the SETTINGS frames should be automatically acknowledged and applied.protected boolean
isServer()
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 Http2PromisedRequestVerifier
promisedRequestVerifier()
Get theHttp2PromisedRequestVerifier
to use.protected B
promisedRequestVerifier(Http2PromisedRequestVerifier promisedRequestVerifier)
Set theHttp2PromisedRequestVerifier
to use.protected B
self()
Returnsthis
.protected B
server(boolean isServer)
protected B
validateHeaders(boolean validateHeaders)
Sets if HTTP headers should be validated according to RFC 7540, 8.1.2.6.
-
-
-
Method Detail
-
initialSettings
protected Http2Settings initialSettings()
Sets theHttp2Settings
to use for the initial connection settings exchange.
-
initialSettings
protected B initialSettings(Http2Settings settings)
Sets theHttp2Settings
to use for the initial connection settings exchange.
-
frameListener
protected Http2FrameListener frameListener()
Returns the listener of inbound frames.- Returns:
Http2FrameListener
if set, ornull
if not set.
-
frameListener
protected B frameListener(Http2FrameListener 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 theHttp2Connection
in milliseconds. Returns -1 if the timeout is indefinite.
-
gracefulShutdownTimeoutMillis
protected B gracefulShutdownTimeoutMillis(long gracefulShutdownTimeoutMillis)
Sets the graceful shutdown timeout of theHttp2Connection
in milliseconds.
-
isServer
protected boolean isServer()
-
server
protected B server(boolean isServer)
-
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
protected B maxReservedStreams(int maxReservedStreams)
Set the maximum number of streams which can be in the reserved state at any given time.
-
connection
protected Http2Connection connection()
Returns theHttp2Connection
to use.- Returns:
Http2Connection
if set, ornull
if not set.
-
connection
protected B connection(Http2Connection connection)
Sets theHttp2Connection
to use.
-
decoder
protected Http2ConnectionDecoder decoder()
Returns theHttp2ConnectionDecoder
to use.- Returns:
Http2ConnectionDecoder
if set, ornull
if not set.
-
encoder
protected Http2ConnectionEncoder encoder()
Returns theHttp2ConnectionEncoder
to use.- Returns:
Http2ConnectionEncoder
if set, ornull
if not set.
-
codec
protected B codec(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder)
Sets theHttp2ConnectionDecoder
andHttp2ConnectionEncoder
to use.
-
isValidateHeaders
protected boolean isValidateHeaders()
Returns if HTTP headers should be validated according to RFC 7540, 8.1.2.6.
-
validateHeaders
protected B validateHeaders(boolean validateHeaders)
Sets if HTTP headers should be validated according to RFC 7540, 8.1.2.6.
-
frameLogger
protected Http2FrameLogger frameLogger()
Returns the logger that is used for the encoder and decoder.- Returns:
Http2FrameLogger
if set, ornull
if not set.
-
frameLogger
protected B frameLogger(Http2FrameLogger 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
protected B encoderEnforceMaxConcurrentStreams(boolean 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.0
means no protection is in place.
-
encoderEnforceMaxQueuedControlFrames
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.
-
headerSensitivityDetector
protected Http2HeadersEncoder.SensitivityDetector headerSensitivityDetector()
Returns theHttp2HeadersEncoder.SensitivityDetector
to use.
-
headerSensitivityDetector
protected B headerSensitivityDetector(Http2HeadersEncoder.SensitivityDetector headerSensitivityDetector)
Sets theHttp2HeadersEncoder.SensitivityDetector
to use.
-
encoderIgnoreMaxHeaderListSize
protected B encoderIgnoreMaxHeaderListSize(boolean ignoreMaxHeaderListSize)
Sets if the SETTINGS_MAX_HEADER_LIST_SIZE should be ignored when encoding headers.- Parameters:
ignoreMaxHeaderListSize
-true
to ignore SETTINGS_MAX_HEADER_LIST_SIZE.- Returns:
- this.
-
initialHuffmanDecodeCapacity
@Deprecated protected B initialHuffmanDecodeCapacity(int initialHuffmanDecodeCapacity)
Deprecated.Huffman decoding no longer depends on having a decode capacity.Does nothing, do not call.
-
promisedRequestVerifier
protected B promisedRequestVerifier(Http2PromisedRequestVerifier promisedRequestVerifier)
Set theHttp2PromisedRequestVerifier
to use.- Returns:
- this.
-
promisedRequestVerifier
protected Http2PromisedRequestVerifier promisedRequestVerifier()
Get theHttp2PromisedRequestVerifier
to use.- Returns:
- the
Http2PromisedRequestVerifier
to 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 protected 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.
-
decoderEnforceMaxConsecutiveEmptyDataFrames
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 protected 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.
-
autoAckSettingsFrame
protected B autoAckSettingsFrame(boolean autoAckSettings)
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:
true
if the SETTINGS frames should be automatically acknowledged and applied.
-
autoAckPingFrame
protected B autoAckPingFrame(boolean 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:
true
if the PING frames should be automatically acknowledged.
-
decoupleCloseAndGoAway
protected B decoupleCloseAndGoAway(boolean decoupleCloseAndGoAway)
Determine if theChannel.close()
should be coupled with goaway and graceful close.- Parameters:
decoupleCloseAndGoAway
-true
to 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
protected B flushPreface(boolean flushPreface)
Determine if the Preface should be automatically flushed when theChannel
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
-true
to automatically flush,false otherwise
.- Returns:
this
.- See Also:
- HTTP/2 Connection Preface
-
flushPreface
protected boolean flushPreface()
Determine if the Preface should be automatically flushed when theChannel
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:
true
if automatically flushed.- See Also:
- HTTP/2 Connection Preface
-
build
protected T build()
Create a newHttp2ConnectionHandler
.
-
build
protected abstract T build(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings) throws Exception
Implement this method to create a newHttp2ConnectionHandler
or 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
protected final B self()
Returnsthis
.
-
-