Http2FrameCodecBuilder
together with Http2MultiplexHandler
.@Deprecated @UnstableApi public class Http2MultiplexCodec extends Http2FrameCodec
When a new stream is created, a new Channel
is created for it. Applications send and
receive Http2StreamFrame
s on the created channel. ByteBuf
s 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.
Http2StreamFrame
s implement the ReferenceCounted
interface, as they carry
reference counted objects (e.g. ByteBuf
s). 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
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.
ChannelHandler
s 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 Http2DataFrame
s are subject to HTTP/2 flow control.ByteToMessageDecoder.Cumulator
ChannelHandler.Sharable
streamKey
COMPOSITE_CUMULATOR, MERGE_CUMULATOR
限定符和类型 | 方法和说明 |
---|---|
void |
channelRead(ChannelHandlerContext ctx,
java.lang.Object msg)
已过时。
Calls
ChannelHandlerContext.fireChannelRead(Object) to forward
to the next ChannelInboundHandler in the ChannelPipeline . |
void |
channelReadComplete(ChannelHandlerContext ctx)
已过时。
Notifies any child streams of the read completion.
|
void |
channelWritabilityChanged(ChannelHandlerContext ctx)
已过时。
Calls
ChannelHandlerContext.fireChannelWritabilityChanged() to forward
to the next ChannelInboundHandler in the ChannelPipeline . |
void |
handlerAdded0(ChannelHandlerContext ctx)
已过时。
|
void |
handlerRemoved0(ChannelHandlerContext ctx)
已过时。
Gets called after the
ByteToMessageDecoder was removed from the actual context and it doesn't handle
events anymore. |
void |
onHttpClientUpgrade()
已过时。
Handles the client-side (cleartext) upgrade from HTTP to HTTP/2.
|
handlerAdded, isGracefulShutdownComplete, onConnectionError, onStreamError, userEventTriggered, write
bind, channelActive, channelInactive, close, closeStream, closeStreamLocal, closeStreamRemote, connect, connection, decode, decoder, deregister, disconnect, encoder, exceptionCaught, flush, frameWriter, goAway, gracefulShutdownTimeoutMillis, gracefulShutdownTimeoutMillis, handleServerHeaderDecodeSizeError, onError, onHttpServerUpgrade, read, resetStream
actualReadableBytes, callDecode, decodeLast, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode
channelRegistered, channelUnregistered
ensureNotSharable, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handlerRemoved
public void onHttpClientUpgrade() throws Http2Exception
Http2ConnectionHandler
onHttpClientUpgrade
在类中 Http2ConnectionHandler
Http2Exception
public final void handlerAdded0(ChannelHandlerContext ctx) throws java.lang.Exception
java.lang.Exception
public final void handlerRemoved0(ChannelHandlerContext ctx) throws java.lang.Exception
ByteToMessageDecoder
ByteToMessageDecoder
was removed from the actual context and it doesn't handle
events anymore.handlerRemoved0
在类中 Http2ConnectionHandler
java.lang.Exception
public final void channelReadComplete(ChannelHandlerContext ctx) throws java.lang.Exception
channelReadComplete
在接口中 ChannelInboundHandler
channelReadComplete
在类中 Http2ConnectionHandler
java.lang.Exception
public final void channelRead(ChannelHandlerContext ctx, java.lang.Object msg) throws java.lang.Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelRead(Object)
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelRead
在接口中 ChannelInboundHandler
channelRead
在类中 ByteToMessageDecoder
java.lang.Exception
public final void channelWritabilityChanged(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelWritabilityChanged()
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelWritabilityChanged
在接口中 ChannelInboundHandler
channelWritabilityChanged
在类中 Http2ConnectionHandler
java.lang.Exception