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

public Class Http2MultiplexCodec

extends Http2FrameCodec
Class Inheritance
Annotations
@Deprecated
@UnstableApi
Imports
io.netty.buffer.ByteBuf, io.netty.channel.Channel, .ChannelConfig, .ChannelFuture, .ChannelHandler, .ChannelHandlerContext, .ChannelPromise, .EventLoop, io.netty.channel.socket.ChannelInputShutdownReadComplete, .ChannelOutputShutdownEvent, io.netty.handler.ssl.SslCloseCompletionEvent, io.netty.util.ReferenceCounted, io.netty.util.internal.UnstableApi, java.util.ArrayDeque, .Queue

Deprecated

use Http2FrameCodecBuilder together with Http2MultiplexHandler.

An HTTP/2 handler that creates child channels for each stream.

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

Some Http2StreamFrames 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 an EventLoop. 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 and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
pack-priv volatile ChannelHandlerContext
private int
private final ChannelHandler
private boolean
private final Queue<AbstractHttp2StreamChannel>
private final ChannelHandler
Inherited from io.netty.handler.codec.http2.Http2FrameCodec:
streamKey

Constructor Summary

AccessConstructor and Description
pack-priv
Http2MultiplexCodec(Http2ConnectionEncoder encoder, Http2ConnectionDecoder decoder, Http2Settings initialSettings, ChannelHandler inboundStreamHandler, ChannelHandler upgradeStreamHandler, boolean decoupleCloseAndGoAway, boolean flushPreface)

Method Summary

Modifier and TypeMethod and Description
public final void
public final void
public final void
pack-priv final void
public final void
public final void
handlerRemoved0(ChannelHandlerContext ctx)

Overrides io.netty.handler.codec.http2.Http2ConnectionHandler.handlerRemoved0.

Gets called after the ByteToMessageDecoder was removed from the actual context and it doesn't handle events anymore.
pack-priv final Http2StreamChannel
pack-priv final void
pack-priv final void
private void
pack-priv final void
public void
onHttpClientUpgrade()

Overrides io.netty.handler.codec.http2.Http2ConnectionHandler.onHttpClientUpgrade.

Handles the client-side (cleartext) upgrade from HTTP to HTTP/2.
pack-priv final void
private void
Inherited from io.netty.handler.codec.http2.Http2FrameCodec:
consumeBytesforEachActiveStreamhandlerAddedisGracefulShutdownCompletenewStreamnumInitializingStreamsonConnectionErroronStreamErroruserEventTriggeredwrite

Field Detail

ctxback to summary
pack-priv volatile ChannelHandlerContext ctx

Hides io.netty.handler.codec.http2.Http2FrameCodec.ctx.

idCountback to summary
private int idCount
inboundStreamHandlerback to summary
private final ChannelHandler inboundStreamHandler
parentReadInProgressback to summary
private boolean parentReadInProgress
readCompletePendingQueueback to summary
private final Queue<AbstractHttp2StreamChannel> readCompletePendingQueue
upgradeStreamHandlerback to summary
private final ChannelHandler upgradeStreamHandler

Constructor Detail

Http2MultiplexCodecback to summary
pack-priv Http2MultiplexCodec(Http2ConnectionEncoder encoder, Http2ConnectionDecoder decoder, Http2Settings initialSettings, ChannelHandler inboundStreamHandler, ChannelHandler upgradeStreamHandler, boolean decoupleCloseAndGoAway, boolean flushPreface)

Method Detail

channelReadback to summary
public final void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception

Overrides io.netty.handler.codec.ByteToMessageDecoder.channelRead.

Implements io.netty.channel.ChannelInboundHandler.channelRead.

Doc from io.netty.channel.ChannelInboundHandlerAdapter.channelRead.

Calls ChannelHandlerContext#fireChannelRead(Object) to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.

Annotations
@Override
channelReadCompleteback to summary
public final void channelReadComplete(ChannelHandlerContext ctx) throws Exception

Overrides io.netty.handler.codec.http2.Http2ConnectionHandler.channelReadComplete.

Implements io.netty.channel.ChannelInboundHandler.channelReadComplete.

Notifies any child streams of the read completion.

Annotations
@Override
channelWritabilityChangedback to summary
public final void channelWritabilityChanged(final ChannelHandlerContext ctx) throws Exception

Overrides io.netty.handler.codec.http2.Http2ConnectionHandler.channelWritabilityChanged.

Implements io.netty.channel.ChannelInboundHandler.channelWritabilityChanged.

Doc from io.netty.channel.ChannelInboundHandlerAdapter.channelWritabilityChanged.

Calls ChannelHandlerContext#fireChannelWritabilityChanged() to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.

Annotations
@Override
flush0back to summary
pack-priv final void flush0(ChannelHandlerContext ctx)
handlerAdded0back to summary
public final void handlerAdded0(ChannelHandlerContext ctx) throws Exception

Overrides io.netty.handler.codec.http2.Http2FrameCodec.handlerAdded0.

Annotations
@Override
handlerRemoved0back to summary
public final void handlerRemoved0(ChannelHandlerContext ctx) throws Exception

Overrides io.netty.handler.codec.http2.Http2ConnectionHandler.handlerRemoved0.

Doc from io.netty.handler.codec.ByteToMessageDecoder.handlerRemoved0.

Gets called after the ByteToMessageDecoder was removed from the actual context and it doesn't handle events anymore.

Annotations
@Override
newOutboundStreamback to summary
pack-priv final Http2StreamChannel newOutboundStream()
onHttp2Frameback to summary
pack-priv final void onHttp2Frame(ChannelHandlerContext ctx, Http2Frame frame)

Overrides io.netty.handler.codec.http2.Http2FrameCodec.onHttp2Frame.

Annotations
@Override
onHttp2FrameStreamExceptionback to summary
pack-priv final void onHttp2FrameStreamException(ChannelHandlerContext ctx, Http2FrameStreamException cause)

Overrides io.netty.handler.codec.http2.Http2FrameCodec.onHttp2FrameStreamException.

Annotations
@Override
onHttp2GoAwayFrameback to summary
private void onHttp2GoAwayFrame(ChannelHandlerContext ctx, final Http2GoAwayFrame goAwayFrame)
onHttp2StreamStateChangedback to summary
pack-priv final void onHttp2StreamStateChanged(ChannelHandlerContext ctx, Http2FrameCodec.DefaultHttp2FrameStream stream)

Overrides io.netty.handler.codec.http2.Http2FrameCodec.onHttp2StreamStateChanged.

Annotations
@Override
onHttpClientUpgradeback to summary
public void onHttpClientUpgrade() throws Http2Exception

Overrides io.netty.handler.codec.http2.Http2ConnectionHandler.onHttpClientUpgrade.

Doc from io.netty.handler.codec.http2.Http2ConnectionHandler.onHttpClientUpgrade.

Handles the client-side (cleartext) upgrade from HTTP to HTTP/2. Reserves local stream 1 for the HTTP/2 response.

Annotations
@Override
onUserEventTriggeredback to summary
pack-priv final void onUserEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception

Overrides io.netty.handler.codec.http2.Http2FrameCodec.onUserEventTriggered.

Annotations
@Override
processPendingReadCompleteQueueback to summary
private void processPendingReadCompleteQueue()
io.netty.handler.codec.http2 back to summary

private final Class Http2MultiplexCodec.Http2MultiplexCodecStreamChannel

extends AbstractHttp2StreamChannel
Class Inheritance

Field Summary

Inherited from io.netty.handler.codec.http2.AbstractHttp2StreamChannel:
CHANNEL_INPUT_SHUTDOWN_READ_COMPLETE_VISITORCHANNEL_OUTPUT_SHUTDOWN_EVENT_VISITORSSL_CLOSE_COMPLETION_EVENT_VISITORWRITABLE_VISITOR

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
protected boolean
protected ChannelHandlerContext
protected ChannelFuture
Inherited from io.netty.handler.codec.http2.AbstractHttp2StreamChannel:
allocbindbindbytesBeforeUnwritablebytesBeforeWritablecloseclosecloseFuturecloseOutboundcloseWithErrorcompareToconfigconnectconnectconnectconnectderegisterderegisterdisconnectdisconnectequalseventLoopfireChildReadfireChildReadCompleteflushhashCodeidisActiveisOpenisRegisteredisWritablelocalAddressmetadatanewFailedFuturenewProgressivePromisenewPromisenewSucceededFutureparentpipelinereadremoteAddressstreamstreamClosedtoStringtrySetWritableunsafevoidPromisewritewritewriteAndFlushwriteAndFlush

Constructor Detail

Http2MultiplexCodecStreamChannelback to summary
pack-priv Http2MultiplexCodecStreamChannel(Http2FrameCodec.DefaultHttp2FrameStream stream, ChannelHandler inboundHandler)

Method Detail

addChannelToReadCompletePendingQueueback to summary
protected void addChannelToReadCompletePendingQueue()

Implements abstract io.netty.handler.codec.http2.AbstractHttp2StreamChannel.addChannelToReadCompletePendingQueue.

Annotations
@Override
flush0back to summary
protected void flush0(ChannelHandlerContext ctx)

Overrides io.netty.handler.codec.http2.AbstractHttp2StreamChannel.flush0.

Annotations
@Override
isParentReadInProgressback to summary
protected boolean isParentReadInProgress()

Implements abstract io.netty.handler.codec.http2.AbstractHttp2StreamChannel.isParentReadInProgress.

Annotations
@Override
parentContextback to summary
protected ChannelHandlerContext parentContext()

Implements abstract io.netty.handler.codec.http2.AbstractHttp2StreamChannel.parentContext.

Annotations
@Override
write0back to summary
protected ChannelFuture write0(ChannelHandlerContext ctx, Object msg)

Overrides io.netty.handler.codec.http2.AbstractHttp2StreamChannel.write0.

Annotations
@Override