Class Http2MultiplexCodec
- All Implemented Interfaces:
ChannelHandler,ChannelInboundHandler,ChannelOutboundHandler,Http2LifecycleManager
When a new stream is created, a new Channel is created for it. Applications send and
receive Http2StreamFrames on the created channel. ByteBufs cannot be processed by the channel;
all writes that reach the head of the pipeline must be an instance of Http2StreamFrame. Writes that reach
the head of the pipeline are processed directly by this handler and cannot be intercepted.
The child channel will be notified of user events that impact the stream, such as Http2GoAwayFrame and Http2ResetFrame, as soon as they occur. Although
Http2GoAwayFrame and Http2ResetFrame signify that the remote is ignoring further
communication, closing of the channel is delayed until any inbound queue is drained with Channel.read(), which follows the default behavior of channels in Netty. Applications are
free to close the channel in response to such events if they don't have use for any queued
messages. Any connection level events like Http2SettingsFrame and Http2GoAwayFrame
will be processed internally and also propagated down the pipeline for other handlers to act on.
Outbound streams are supported via the Http2StreamChannelBootstrap.
ChannelConfig.setMaxMessagesPerRead(int) and ChannelConfig.setAutoRead(boolean) are supported.
Reference Counting
SomeHttp2StreamFrames implement the ReferenceCounted interface, as they carry
reference counted objects (e.g. ByteBufs). The multiplex codec will call ReferenceCounted.retain()
before propagating a reference counted object through the pipeline, and thus an application handler needs to release
such an object after having consumed it. For more information on reference counting take a look at
https://netty.io/wiki/reference-counted-objects.html
Channel Events
A child channel becomes active as soon as it is registered to anEventLoop. Therefore, an active channel
does not map to an active HTTP/2 stream immediately. Only once a Http2HeadersFrame has been successfully sent
or received, does the channel map to an active HTTP/2 stream. In case it is not possible to open a new HTTP/2 stream
(i.e. due to the maximum number of active streams being exceeded), the child channel receives an exception
indicating the cause and is closed immediately thereafter.
Writability and Flow Control
A child channel observes outbound/remote flow control via the channel's writability. A channel only becomes writable when it maps to an active HTTP/2 stream and the stream's flow control window is greater than zero. A child channel does not know about the connection-level flow control window.ChannelHandlers are free to ignore the
channel's writability, in which case the excessive writes will be buffered by the parent channel. It's important to
note that only Http2DataFrames are subject to HTTP/2 flow control.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final classDeprecated.Nested classes/interfaces inherited from class io.netty.handler.codec.http2.Http2FrameCodec
Http2FrameCodec.DefaultHttp2FrameStreamNested classes/interfaces inherited from class io.netty.handler.codec.ByteToMessageDecoder
ByteToMessageDecoder.CumulatorNested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescription(package private) ChannelHandlerContextDeprecated.private intDeprecated.private final ChannelHandlerDeprecated.private booleanDeprecated.private final Queue<AbstractHttp2StreamChannel> Deprecated.private final ChannelHandlerDeprecated.Fields inherited from class io.netty.handler.codec.http2.Http2FrameCodec
streamKeyFields inherited from class io.netty.handler.codec.ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR -
Constructor Summary
ConstructorsConstructorDescriptionHttp2MultiplexCodec(Http2ConnectionEncoder encoder, Http2ConnectionDecoder decoder, Http2Settings initialSettings, ChannelHandler inboundStreamHandler, ChannelHandler upgradeStreamHandler, boolean decoupleCloseAndGoAway, boolean flushPreface) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidchannelRead(ChannelHandlerContext ctx, Object msg) Deprecated.CallsChannelHandlerContext.fireChannelRead(Object)to forward to the nextChannelInboundHandlerin theChannelPipeline.final voidDeprecated.Notifies any child streams of the read completion.final voidDeprecated.CallsChannelHandlerContext.fireChannelWritabilityChanged()to forward to the nextChannelInboundHandlerin theChannelPipeline.(package private) final voidDeprecated.final voidDeprecated.final voidDeprecated.Gets called after theByteToMessageDecoderwas removed from the actual context and it doesn't handle events anymore.(package private) final Http2StreamChannelDeprecated.(package private) final voidonHttp2Frame(ChannelHandlerContext ctx, Http2Frame frame) Deprecated.(package private) final voidDeprecated.private voidonHttp2GoAwayFrame(ChannelHandlerContext ctx, Http2GoAwayFrame goAwayFrame) Deprecated.(package private) final voidonHttp2StreamStateChanged(ChannelHandlerContext ctx, Http2FrameCodec.DefaultHttp2FrameStream stream) Deprecated.voidDeprecated.Handles the client-side (cleartext) upgrade from HTTP to HTTP/2.(package private) final voidonUserEventTriggered(ChannelHandlerContext ctx, Object evt) Deprecated.private voidDeprecated.Methods inherited from class io.netty.handler.codec.http2.Http2FrameCodec
consumeBytes, forEachActiveStream, handlerAdded, isGracefulShutdownComplete, newHttp2UnknownFrame, newStream, numInitializingStreams, onConnectionError, onStreamError, userEventTriggered, writeMethods inherited from class io.netty.handler.codec.http2.Http2ConnectionHandler
bind, channelActive, channelInactive, channelReadComplete0, close, closeStream, closeStreamLocal, closeStreamRemote, connect, connection, decode, decoder, deregister, disconnect, encoder, exceptionCaught, flush, frameWriter, goAway, gracefulShutdownTimeoutMillis, gracefulShutdownTimeoutMillis, handleServerHeaderDecodeSizeError, onError, onHttpServerUpgrade, read, resetStreamMethods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, callDecode, decodeLast, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecodeMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelRegistered, channelUnregisteredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerRemoved
-
Field Details
-
inboundStreamHandler
Deprecated. -
upgradeStreamHandler
Deprecated. -
readCompletePendingQueue
Deprecated. -
parentReadInProgress
private boolean parentReadInProgressDeprecated. -
idCount
private int idCountDeprecated. -
ctx
Deprecated.
-
-
Constructor Details
-
Http2MultiplexCodec
Http2MultiplexCodec(Http2ConnectionEncoder encoder, Http2ConnectionDecoder decoder, Http2Settings initialSettings, ChannelHandler inboundStreamHandler, ChannelHandler upgradeStreamHandler, boolean decoupleCloseAndGoAway, boolean flushPreface) Deprecated.
-
-
Method Details
-
onHttpClientUpgrade
Deprecated.Description copied from class:Http2ConnectionHandlerHandles the client-side (cleartext) upgrade from HTTP to HTTP/2. Reserves local stream 1 for the HTTP/2 response.- Overrides:
onHttpClientUpgradein classHttp2ConnectionHandler- Throws:
Http2Exception
-
handlerAdded0
Deprecated.- Overrides:
handlerAdded0in classHttp2FrameCodec- Throws:
Exception
-
handlerRemoved0
Deprecated.Description copied from class:ByteToMessageDecoderGets called after theByteToMessageDecoderwas removed from the actual context and it doesn't handle events anymore.- Overrides:
handlerRemoved0in classHttp2ConnectionHandler- Throws:
Exception
-
onHttp2Frame
Deprecated.- Overrides:
onHttp2Framein classHttp2FrameCodec
-
onHttp2StreamStateChanged
final void onHttp2StreamStateChanged(ChannelHandlerContext ctx, Http2FrameCodec.DefaultHttp2FrameStream stream) Deprecated.- Overrides:
onHttp2StreamStateChangedin classHttp2FrameCodec
-
newOutboundStream
Deprecated. -
onHttp2FrameStreamException
Deprecated.- Overrides:
onHttp2FrameStreamExceptionin classHttp2FrameCodec
-
onHttp2GoAwayFrame
Deprecated. -
channelReadComplete
Deprecated.Notifies any child streams of the read completion.- Specified by:
channelReadCompletein interfaceChannelInboundHandler- Overrides:
channelReadCompletein classHttp2ConnectionHandler- Throws:
Exception
-
processPendingReadCompleteQueue
private void processPendingReadCompleteQueue()Deprecated. -
channelRead
Deprecated.Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelRead(Object)to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelReadin interfaceChannelInboundHandler- Overrides:
channelReadin classByteToMessageDecoder- Throws:
Exception
-
channelWritabilityChanged
Deprecated.Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelWritabilityChanged()to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelWritabilityChangedin interfaceChannelInboundHandler- Overrides:
channelWritabilityChangedin classHttp2ConnectionHandler- Throws:
Exception
-
onUserEventTriggered
Deprecated.- Overrides:
onUserEventTriggeredin classHttp2FrameCodec- Throws:
Exception
-
flush0
Deprecated.
-
Http2FrameCodecBuildertogether withHttp2MultiplexHandler.