public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http2LifecycleManager
Http2FrameListener
This class will read HTTP/2 frames and delegate the events to a Http2FrameListener
This interface enforces inbound flow control functionality through
Http2LocalFlowController
ByteToMessageDecoder.CumulatorChannelHandler.Sharable, ChannelHandler.SkipCOMPOSITE_CUMULATOR, MERGE_CUMULATOR| Constructor and Description |
|---|
Http2ConnectionHandler(boolean server,
Http2FrameListener listener) |
Http2ConnectionHandler(Http2ConnectionDecoder.Builder decoderBuilder,
Http2ConnectionEncoder.Builder encoderBuilder)
Constructor for pre-configured encoder and decoder builders.
|
Http2ConnectionHandler(Http2Connection connection,
Http2FrameListener listener) |
Http2ConnectionHandler(Http2Connection connection,
Http2FrameReader frameReader,
Http2FrameWriter frameWriter,
Http2FrameListener listener) |
| Modifier and Type | Method and Description |
|---|---|
void |
channelActive(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.fireChannelActive() to forward
to the next ChannelHandler in the ChannelPipeline. |
void |
channelInactive(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.fireChannelInactive() to forward
to the next ChannelHandler in the ChannelPipeline. |
void |
close(ChannelHandlerContext ctx,
ChannelPromise promise)
Calls
ChannelHandlerContext.close(ChannelPromise) to forward
to the next ChannelHandler in the ChannelPipeline. |
void |
closeLocalSide(Http2Stream stream,
ChannelFuture future)
Closes the local side of the given stream.
|
void |
closeRemoteSide(Http2Stream stream,
ChannelFuture future)
Closes the remote side of the given stream.
|
void |
closeStream(Http2Stream stream,
ChannelFuture future)
Closes the given stream and adds a hook to close the channel after the given future
completes.
|
Http2Connection |
connection() |
protected void |
decode(ChannelHandlerContext ctx,
ByteBuf in,
List<Object> out)
Decode the from one
ByteBuf to an other. |
Http2ConnectionDecoder |
decoder() |
Http2ConnectionEncoder |
encoder() |
void |
exceptionCaught(ChannelHandlerContext ctx,
Throwable cause)
Handles
Http2Exception objects that were thrown from other handlers. |
protected Http2FrameWriter |
frameWriter() |
void |
handlerAdded(ChannelHandlerContext ctx)
Do nothing by default, sub-classes may override this method.
|
protected void |
handlerRemoved0(ChannelHandlerContext ctx)
Gets called after the
ByteToMessageDecoder was removed from the actual context and it doesn't handle
events anymore. |
protected void |
onConnectionError(ChannelHandlerContext ctx,
Throwable cause,
Http2Exception http2Ex)
Handler for a connection error.
|
void |
onException(ChannelHandlerContext ctx,
Throwable cause)
Central handler for all exceptions caught during HTTP/2 processing.
|
void |
onHttpClientUpgrade()
Handles the client-side (cleartext) upgrade from HTTP to HTTP/2.
|
void |
onHttpServerUpgrade(Http2Settings settings)
Handles the server-side (cleartext) upgrade from HTTP to HTTP/2.
|
protected void |
onStreamError(ChannelHandlerContext ctx,
Throwable cause,
Http2Exception.StreamException http2Ex)
Handler for a stream error.
|
ChannelFuture |
writeGoAway(ChannelHandlerContext ctx,
int lastStreamId,
long errorCode,
ByteBuf debugData,
ChannelPromise promise)
Sends a
GO_AWAY frame to the remote endpoint and updates the connection state appropriately. |
ChannelFuture |
writeRstStream(ChannelHandlerContext ctx,
int streamId,
long errorCode,
ChannelPromise promise)
Writes a
RST_STREAM frame to the remote endpoint and updates the connection state appropriately. |
actualReadableBytes, callDecode, channelRead, channelReadComplete, decodeLast, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setSingleDecodebind, channelRegistered, channelUnregistered, channelWritabilityChanged, connect, deregister, disconnect, flush, isSharable, read, userEventTriggered, writepublic Http2ConnectionHandler(boolean server,
Http2FrameListener listener)
public Http2ConnectionHandler(Http2Connection connection, Http2FrameListener listener)
public Http2ConnectionHandler(Http2Connection connection, Http2FrameReader frameReader, Http2FrameWriter frameWriter, Http2FrameListener listener)
public Http2ConnectionHandler(Http2ConnectionDecoder.Builder decoderBuilder, Http2ConnectionEncoder.Builder encoderBuilder)
this as the
Http2LifecycleManager and builds them.public Http2Connection connection()
public Http2ConnectionDecoder decoder()
public Http2ConnectionEncoder encoder()
public void onHttpClientUpgrade()
throws Http2Exception
Http2Exceptionpublic void onHttpServerUpgrade(Http2Settings settings) throws Http2Exception
settings - the settings for the remote endpoint.Http2Exceptionpublic void channelActive(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapterChannelHandlerContext.fireChannelActive() to forward
to the next ChannelHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelActive in interface ChannelHandlerchannelActive in class ChannelHandlerAdapterExceptionpublic void handlerAdded(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapterhandlerAdded in interface ChannelHandlerhandlerAdded in class ChannelHandlerAdapterExceptionprotected void handlerRemoved0(ChannelHandlerContext ctx) throws Exception
ByteToMessageDecoderByteToMessageDecoder was removed from the actual context and it doesn't handle
events anymore.handlerRemoved0 in class ByteToMessageDecoderExceptionpublic void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
ChannelHandlerAdapterChannelHandlerContext.close(ChannelPromise) to forward
to the next ChannelHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.close in interface ChannelHandlerclose in class ChannelHandlerAdapterctx - the ChannelHandlerContext for which the close operation is madepromise - the ChannelPromise to notify once the operation completesException - thrown if an error accourpublic void channelInactive(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapterChannelHandlerContext.fireChannelInactive() to forward
to the next ChannelHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelInactive in interface ChannelHandlerchannelInactive in class ByteToMessageDecoderExceptionpublic void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
Http2Exception objects that were thrown from other handlers. Ignores all other exceptions.exceptionCaught in interface ChannelHandlerexceptionCaught in class ChannelHandlerAdapterExceptionpublic void closeLocalSide(Http2Stream stream, ChannelFuture future)
closeLocalSide in interface Http2LifecycleManagerstream - the stream to be half closed.future - If closing, the future after which to close the channel.public void closeRemoteSide(Http2Stream stream, ChannelFuture future)
closeRemoteSide in interface Http2LifecycleManagerstream - the stream to be half closed.future - If closing, the future after which to close the channel.public void closeStream(Http2Stream stream, ChannelFuture future)
closeStream in interface Http2LifecycleManagerstream - the stream to be closed.future - the future after which to close the channel.public void onException(ChannelHandlerContext ctx, Throwable cause)
onException in interface Http2LifecycleManagerprotected void onConnectionError(ChannelHandlerContext ctx, Throwable cause, Http2Exception http2Ex)
ctx - the channel contextcause - the exception that was caughthttp2Ex - the Http2Exception that is embedded in the causality chain. This may
be null if it's an unknown exception.protected void onStreamError(ChannelHandlerContext ctx, Throwable cause, Http2Exception.StreamException http2Ex)
RST_STREAM frame to the remote endpoint and closes the
stream.ctx - the channel contextcause - the exception that was caughthttp2Ex - the Http2Exception.StreamException that is embedded in the causality chain.protected Http2FrameWriter frameWriter()
public ChannelFuture writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode, ChannelPromise promise)
RST_STREAM frame to the remote endpoint and updates the connection state appropriately.writeRstStream in interface Http2LifecycleManagerpublic ChannelFuture writeGoAway(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData, ChannelPromise promise)
GO_AWAY frame to the remote endpoint and updates the connection state appropriately.writeGoAway in interface Http2LifecycleManagerprotected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
ByteToMessageDecoderByteBuf to an other. This method will be called till either the input
ByteBuf has nothing to read when return from this method or till nothing was read from the input
ByteBuf.decode in class ByteToMessageDecoderctx - the ChannelHandlerContext which this ByteToMessageDecoder belongs toin - the ByteBuf from which to read dataout - the List to which decoded messages should be addedException - is thrown if an error accourCopyright © 2008–2015 The Netty Project. All rights reserved.