Package io.netty.handler.codec.http2
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 java.lang.ObjectAbstract base class which defines commonly used features required to buildHttp2ConnectionHandlerinstances.Three ways to build a
Http2ConnectionHandlerLet the builder create a
Simply call all the necessary setter methods, and then useHttp2ConnectionHandlerbuild()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
CallHttp2ConnectionHandleryou specifiedconnection(Http2Connection)to tell the builder that you want to build the handler from theHttp2Connectionyou specified. Setting the following properties are prohibited and thus will trigger anIllegalStateExceptionbecause they conflict with this option.Let the builder use the
CallHttp2ConnectionDecoderandHttp2ConnectionEncoderyou specifiedcodec(Http2ConnectionDecoder, Http2ConnectionEncoder)to tell the builder that you want to built the handler from theHttp2ConnectionDecoderandHttp2ConnectionEncoderyou specified. Setting the following properties are prohibited and thus will trigger anIllegalStateExceptionbecause 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 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 Http2Connectionconnection()Returns theHttp2Connectionto use.protected Bconnection(Http2Connection connection)Sets theHttp2Connectionto use.protected Http2ConnectionDecoderdecoder()Returns theHttp2ConnectionDecoderto use.protected intdecoderEnforceMaxConsecutiveEmptyDataFrames()Returns 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 booleandecoupleCloseAndGoAway()Determine 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 booleanencoderEnforceMaxConcurrentStreams()Returns 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 intencoderEnforceMaxQueuedControlFrames()Returns 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 booleanflushPreface()protected BflushPreface(boolean flushPreface)protected Http2FrameListenerframeListener()Returns the listener of inbound frames.protected BframeListener(Http2FrameListener frameListener)Sets the listener of inbound frames.protected Http2FrameLoggerframeLogger()Returns 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 longgracefulShutdownTimeoutMillis()Returns the graceful shutdown timeout of theHttp2Connectionin milliseconds.protected BgracefulShutdownTimeoutMillis(long gracefulShutdownTimeoutMillis)Sets the graceful shutdown timeout of theHttp2Connectionin milliseconds.protected Http2HeadersEncoder.SensitivityDetectorheaderSensitivityDetector()Returns 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 Http2SettingsinitialSettings()Sets theHttp2Settingsto use for the initial connection settings exchange.protected BinitialSettings(Http2Settings settings)Sets theHttp2Settingsto use for the initial connection settings exchange.protected booleanisAutoAckPingFrame()Determine if the PING frames should be automatically acknowledged or not.protected booleanisAutoAckSettingsFrame()Determine if the SETTINGS frames should be automatically acknowledged and applied.protected booleanisServer()protected booleanisValidateHeaders()Returns if HTTP headers should be validated according to RFC 7540, 8.1.2.6.protected intmaxReservedStreams()Get 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 Http2PromisedRequestVerifierpromisedRequestVerifier()Get theHttp2PromisedRequestVerifierto use.protected BpromisedRequestVerifier(Http2PromisedRequestVerifier promisedRequestVerifier)Set theHttp2PromisedRequestVerifierto use.protected 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.
-
-
-
Method Detail
-
initialSettings
protected Http2Settings initialSettings()
Sets theHttp2Settingsto use for the initial connection settings exchange.
-
initialSettings
protected B initialSettings(Http2Settings settings)
Sets theHttp2Settingsto use for the initial connection settings exchange.
-
frameListener
protected Http2FrameListener frameListener()
Returns the listener of inbound frames.- Returns:
Http2FrameListenerif set, ornullif 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 theHttp2Connectionin milliseconds. Returns -1 if the timeout is indefinite.
-
gracefulShutdownTimeoutMillis
protected B gracefulShutdownTimeoutMillis(long gracefulShutdownTimeoutMillis)
Sets the graceful shutdown timeout of theHttp2Connectionin 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 theHttp2Connectionto use.- Returns:
Http2Connectionif set, ornullif not set.
-
connection
protected B connection(Http2Connection connection)
Sets theHttp2Connectionto use.
-
decoder
protected Http2ConnectionDecoder decoder()
Returns theHttp2ConnectionDecoderto use.- Returns:
Http2ConnectionDecoderif set, ornullif not set.
-
encoder
protected Http2ConnectionEncoder encoder()
Returns theHttp2ConnectionEncoderto use.- Returns:
Http2ConnectionEncoderif set, ornullif not set.
-
codec
protected B codec(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder)
Sets theHttp2ConnectionDecoderandHttp2ConnectionEncoderto 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:
Http2FrameLoggerif set, ornullif 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.0means 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.0means no protection should be applied.
-
headerSensitivityDetector
protected Http2HeadersEncoder.SensitivityDetector headerSensitivityDetector()
Returns theHttp2HeadersEncoder.SensitivityDetectorto use.
-
headerSensitivityDetector
protected B headerSensitivityDetector(Http2HeadersEncoder.SensitivityDetector headerSensitivityDetector)
Sets theHttp2HeadersEncoder.SensitivityDetectorto use.
-
encoderIgnoreMaxHeaderListSize
protected B encoderIgnoreMaxHeaderListSize(boolean ignoreMaxHeaderListSize)
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 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 theHttp2PromisedRequestVerifierto use.- Returns:
- this.
-
promisedRequestVerifier
protected Http2PromisedRequestVerifier 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
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.0means no protection should be applied.
-
decoderEnforceMaxRstFramesPerWindow
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.0for any of the parameters means no protection should be applied.
-
encoderEnforceMaxRstFramesPerWindow
protected B encoderEnforceMaxRstFramesPerWindow(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 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
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:
trueif 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:
trueif 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-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
protected B flushPreface(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.
- Parameters:
flushPreface-trueto 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 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:
- HTTP/2 Connection Preface
-
build
protected T build()
Create a newHttp2ConnectionHandler.
-
build
protected abstract T build(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings) throws java.lang.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:
java.lang.Exception
-
self
protected final B self()
Returnsthis.
-
-