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

public Class Http2ConnectionHandler

extends ByteToMessageDecoder
implements Http2LifecycleManager, ChannelOutboundHandler
Class Inheritance
All Implemented Interfaces
io.netty.channel.ChannelOutboundHandler, io.netty.channel.ChannelHandler, io.netty.handler.codec.http2.Http2LifecycleManager
Known Direct Subclasses
io.netty.handler.codec.http2.Http2FrameCodec, io.netty.handler.codec.http2.HttpToHttp2ConnectionHandler
Annotations
@UnstableApi
Imports
io.netty.buffer.ByteBuf, .ByteBufUtil, .Unpooled, io.netty.channel.ChannelFuture, .ChannelFutureListener, .ChannelHandlerContext, .ChannelOutboundHandler, .ChannelPromise, io.netty.handler.codec.ByteToMessageDecoder, io.netty.handler.codec.http.HttpResponseStatus, io.netty.handler.codec.http2.Http2Exception.CompositeStreamException, .Http2Exception.StreamException, io.netty.util.CharsetUtil, io.netty.util.concurrent.Future, io.netty.util.internal.UnstableApi, io.netty.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.net.SocketAddress, java.util.List, java.util.concurrent.TimeUnit

Provides the default implementation for processing inbound frame events and delegates to a Http2FrameListener

This class will read HTTP/2 frames and delegate the events to a Http2FrameListener

This interface enforces inbound flow control functionality through Http2LocalFlowController

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract class
private static class
Http2ConnectionHandler.ClosingChannelFutureListener

Closes the channel when the future completes.

private class
private class

Field Summary

Modifier and TypeField and Description
private Http2ConnectionHandler.BaseDecoder
private ChannelFutureListener
private final Http2ConnectionDecoder
private final boolean
private final Http2ConnectionEncoder
private final boolean
private long
private static final Http2Headers
private static final ByteBuf
private final Http2Settings
private static final InternalLogger
Inherited from io.netty.handler.codec.ByteToMessageDecoder:
COMPOSITE_CUMULATORMERGE_CUMULATOR

Constructor Summary

AccessConstructor and Description
protected
protected
Http2ConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, boolean decoupleCloseAndGoAway)

protected
Http2ConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, boolean decoupleCloseAndGoAway, boolean flushPreface)

Method Summary

Modifier and TypeMethod and Description
public void
bind(ChannelHandlerContext
the ChannelHandlerContext for which the bind operation is made
ctx
,
SocketAddress
the SocketAddress to which it should bound
localAddress
,
ChannelPromise
the ChannelPromise to notify once the operation completes
promise
)

Implements io.netty.channel.ChannelOutboundHandler.bind.

Called once a bind operation is made.
public void
public void
public void
pack-priv final void
public void
private void
checkCloseConnection(ChannelFuture
Represents the status that will be passed to the closeListener.
future
)

Closes the connection if the graceful shutdown process has completed.

private static ByteBuf
clientPrefaceString(Http2Connection connection)

Returns the client preface string if this is a client connection, otherwise returns null.

public void
close(ChannelHandlerContext
the ChannelHandlerContext for which the close operation is made
ctx
,
ChannelPromise
the ChannelPromise to notify once the operation completes
promise
)

Implements io.netty.channel.ChannelOutboundHandler.close.

Called once a close operation is made.
private void
public void
closeStream(final Http2Stream
the stream to be closed and deactivated.
stream
,
ChannelFuture
when completed if Http2Connection#numActiveStreams() is 0 then the underlying channel will be closed.
future
)

Implements io.netty.handler.codec.http2.Http2LifecycleManager.closeStream.

Closes and deactivates the given stream.
public void
closeStreamLocal(Http2Stream
the stream to be half closed.
stream
,
ChannelFuture
If closing, the future after which to close the channel.
future
)

Implements io.netty.handler.codec.http2.Http2LifecycleManager.closeStreamLocal.

Closes the local side of the given stream.
public void
closeStreamRemote(Http2Stream
the stream to be half closed.
stream
,
ChannelFuture
If closing, the future after which to close the channel.
future
)

Implements io.netty.handler.codec.http2.Http2LifecycleManager.closeStreamRemote.

Closes the remote side of the given stream.
public void
connect(ChannelHandlerContext
the ChannelHandlerContext for which the connect operation is made
ctx
,
SocketAddress
the SocketAddress to which it should connect
remoteAddress
,
SocketAddress
the SocketAddress which is used as source on connect
localAddress
,
ChannelPromise
the ChannelPromise to notify once the operation completes
promise
)

Implements io.netty.channel.ChannelOutboundHandler.connect.

Called once a connect operation is made.
public Http2Connection
protected void
decode(ChannelHandlerContext ctx, ByteBuf
the ByteBuf from which to read data
in
,
List<Object>
the List to which decoded messages should be added
out
)

Implements abstract io.netty.handler.codec.ByteToMessageDecoder.decode.

Decode the from one ByteBuf to an other.
public Http2ConnectionDecoder
public void
deregister(ChannelHandlerContext
the ChannelHandlerContext for which the close operation is made
ctx
,
ChannelPromise
the ChannelPromise to notify once the operation completes
promise
)

Implements io.netty.channel.ChannelOutboundHandler.deregister.

Called once a deregister operation is made from the current registered EventLoop.
public void
disconnect(ChannelHandlerContext
the ChannelHandlerContext for which the disconnect operation is made
ctx
,
ChannelPromise
the ChannelPromise to notify once the operation completes
promise
)

Implements io.netty.channel.ChannelOutboundHandler.disconnect.

Called once a disconnect operation is made.
private void
doCloseStream(final Http2Stream stream, ChannelFuture future)

private void
public Http2ConnectionEncoder
public void
public void
flush(ChannelHandlerContext
the ChannelHandlerContext for which the flush operation is made
ctx
)

Implements io.netty.channel.ChannelOutboundHandler.flush.

Called once a flush operation is made.
protected Http2FrameWriter
public ChannelFuture
goAway(final ChannelHandlerContext
The context used for communication and buffer allocation if necessary.
ctx
,
final int
The last stream that the local endpoint is claiming it will accept.
lastStreamId
,
final long
The rational as to why the connection is being closed. See Http2Error.
errorCode
,
final ByteBuf
For diagnostic purposes (carries no semantic value).
debugData
,
ChannelPromise
Used to indicate the return status of this operation.
promise
)

Implements io.netty.handler.codec.http2.Http2LifecycleManager.goAway.

Prevents the peer from creating streams and close the connection if errorCode is not Http2Error#NO_ERROR.
private ChannelFuture
goAway(ChannelHandlerContext ctx, Http2Exception cause, ChannelPromise promise)

Close the remote endpoint with a GO_AWAY frame.

public long
gracefulShutdownTimeoutMillis()

Get the amount of time (in milliseconds) this endpoint will wait for all streams to be closed before closing the connection during the graceful shutdown process.

public void
gracefulShutdownTimeoutMillis(long
the amount of time (in milliseconds) this endpoint will wait for all streams to be closed before closing the connection during the graceful shutdown process.
gracefulShutdownTimeoutMillis
)

Set the amount of time (in milliseconds) this endpoint will wait for all streams to be closed before closing the connection during the graceful shutdown process.

public void
handlerAdded(ChannelHandlerContext ctx)

Overrides io.netty.channel.ChannelHandlerAdapter.handlerAdded.

Implements io.netty.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.
protected void
handlerRemoved0(ChannelHandlerContext ctx)

Overrides io.netty.handler.codec.ByteToMessageDecoder.handlerRemoved0.

Gets called after the ByteToMessageDecoder was removed from the actual context and it doesn't handle events anymore.
protected void
handleServerHeaderDecodeSizeError(ChannelHandlerContext
the channel context
ctx
,
Http2Stream
the Http2Stream on which the header was received
stream
)

Notifies client that this server has received headers that are larger than what it is willing to accept.

protected boolean
isGracefulShutdownComplete()

Called by the graceful shutdown logic to determine when it is safe to close the connection.

private ChannelFutureListener
protected void
onConnectionError(ChannelHandlerContext
the channel context
ctx
,
boolean
true if the error was caused by an outbound operation.
outbound
,
Throwable
the exception that was caught
cause
,
Http2Exception
the Http2Exception that is embedded in the causality chain. This may be null if it's an unknown exception.
http2Ex
)

Handler for a connection error.

public void
onError(ChannelHandlerContext
The context used for communication and buffer allocation if necessary.
ctx
,
boolean
true if the error was caused by an outbound operation and so the corresponding ChannelPromise was failed as well.
outbound
,
Throwable
the error.
cause
)

Implements io.netty.handler.codec.http2.Http2LifecycleManager.onError.

Central handler for all exceptions caught during HTTP/2 processing.
public void
onHttpClientUpgrade()

Handles the client-side (cleartext) upgrade from HTTP to HTTP/2.

public void
onHttpServerUpgrade(Http2Settings
the settings for the remote endpoint.
settings
)

Handles the server-side (cleartext) upgrade from HTTP to HTTP/2.

protected void
onStreamError(ChannelHandlerContext
the channel context
ctx
,
boolean
true if the error was caused by an outbound operation.
outbound
,
Throwable
the exception that was caught
cause
,
Http2Exception.StreamException
the StreamException that is embedded in the causality chain.
http2Ex
)

Handler for a stream error.

private boolean
private static void
processGoAwayWriteResult(final ChannelHandlerContext ctx, final int lastStreamId, final long errorCode, final ByteBuf debugData, ChannelFuture future)

private void
public void
public ChannelFuture
resetStream(final ChannelHandlerContext
The context used for communication and buffer allocation if necessary.
ctx
,
int
The identifier of the stream to reset.
streamId
,
long
Justification as to why this stream is being reset. See Http2Error.
errorCode
,
ChannelPromise
Used to indicate the return status of this operation.
promise
)

Implements io.netty.handler.codec.http2.Http2LifecycleManager.resetStream.

Ensure the stream identified by streamId is reset.
private ChannelFuture
resetStream(final ChannelHandlerContext ctx, final Http2Stream stream, long errorCode, ChannelPromise promise)

private ChannelFuture
resetUnknownStream(final ChannelHandlerContext ctx, int streamId, long errorCode, ChannelPromise promise)

Sends a RST_STREAM frame even if we don't know about the stream.

public void
write(ChannelHandlerContext
the ChannelHandlerContext for which the write operation is made
ctx
,
Object
the message to write
msg
,
ChannelPromise
the ChannelPromise to notify once the operation completes
promise
)

Implements io.netty.channel.ChannelOutboundHandler.write.

Called once a write operation is made.
Inherited from io.netty.handler.codec.ByteToMessageDecoder:
actualReadableBytescallDecodechannelReaddecodeLastdiscardSomeReadByteshandlerRemovedinternalBufferisSingleDecodesetCumulatorsetDiscardAfterReadssetSingleDecodeuserEventTriggered