Top Description Methods
io.netty5.handler.codec.http2

public Interface Http2LifecycleManager

Known Direct Implementers
io.netty5.handler.codec.http2.Http2ConnectionHandler
Annotations
@UnstableApi
Imports
io.netty5.buffer.Buffer, io.netty5.channel.ChannelHandlerContext, io.netty5.util.concurrent.Future, .Promise, io.netty5.util.internal.UnstableApi

Manager for the life cycle of the HTTP/2 connection. Handles graceful shutdown of the channel, closing only after all of the streams have closed.

Method Summary

Modifier and TypeMethod and Description
public void
closeStream(Http2Stream
the stream to be closed and deactivated.
stream
,
Future<Void>
when completed if Http2Connection#numActiveStreams() is 0 then the underlying channel will be closed.
future
)

Closes and deactivates the given stream.

public void
closeStreamLocal(Http2Stream
the stream to be half closed.
stream
,
Future<Void> future)

Closes the local side of the stream.

public void
closeStreamRemote(Http2Stream
the stream to be half closed.
stream
,
Future<Void> future)

Closes the remote side of the stream.

public Future<Void>

Returns:

Will be considered successful when the connection and stream state has been updated, and a GO_AWAY frame has been sent to the peer. If the stream state has already been updated and a GO_AWAY frame has been sent then the return status may indicate success immediately.
goAway
(ChannelHandlerContext
The context used for communication and buffer allocation if necessary.
ctx
,
int
The last stream that the local endpoint is claiming it will accept.
lastStreamId
,
long
The rational as to why the connection is being closed. See Http2Error.
errorCode
,
Buffer
For diagnostic purposes (carries no semantic value).
debugData
)

Prevents the peer from creating streams and close the connection if errorCode is not Http2Error#NO_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 Promise was failed as well.
outbound
,
Throwable
the error.
cause
)

Processes the given error.

public Future<Void>

Returns:

Will be considered successful when the connection and stream state has been updated, and a RST_STREAM frame has been sent to the peer. If the stream state has already been updated and a RST_STREAM frame has been sent then the return status may indicate success immediately.
resetStream
(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
)

Ensure the stream identified by streamId is reset.

Method Detail

closeStreamback to summary
public void closeStream(Http2Stream stream, Future<Void> future)

Closes and deactivates the given stream. A listener is also attached to future and upon completion the underlying channel will be closed if Http2Connection#numActiveStreams() is 0.

Parameters
stream:Http2Stream

the stream to be closed and deactivated.

future:Future<Void>

when completed if Http2Connection#numActiveStreams() is 0 then the underlying channel will be closed.

closeStreamLocalback to summary
public void closeStreamLocal(Http2Stream stream, Future<Void> future)

Closes the local side of the stream. Depending on the stream state this may result in stream being closed. See closeStream(Http2Stream, Future).

Parameters
stream:Http2Stream

the stream to be half closed.

future:Future<Void>

See closeStream(Http2Stream, Future).

closeStreamRemoteback to summary
public void closeStreamRemote(Http2Stream stream, Future<Void> future)

Closes the remote side of the stream. Depending on the stream state this may result in stream being closed. See closeStream(Http2Stream, Future).

Parameters
stream:Http2Stream

the stream to be half closed.

future:Future<Void>

See closeStream(Http2Stream, Future).

goAwayback to summary
public Future<Void> goAway(ChannelHandlerContext ctx, int lastStreamId, long errorCode, Buffer debugData)

Prevents the peer from creating streams and close the connection if errorCode is not Http2Error#NO_ERROR. After this call the peer is not allowed to create any new streams and the local endpoint will be limited to creating streams with stream identifier <= lastStreamId. This may result in sending a GO_AWAY frame (assuming we have not already sent one with Last-Stream-ID <= lastStreamId), or may just return success if a GO_AWAY has previously been sent.

Parameters
ctx:ChannelHandlerContext

The context used for communication and buffer allocation if necessary.

lastStreamId:int

The last stream that the local endpoint is claiming it will accept.

errorCode:long

The rational as to why the connection is being closed. See Http2Error.

debugData:Buffer

For diagnostic purposes (carries no semantic value).

Returns:Future<Void>

Will be considered successful when the connection and stream state has been updated, and a GO_AWAY frame has been sent to the peer. If the stream state has already been updated and a GO_AWAY frame has been sent then the return status may indicate success immediately.

onErrorback to summary
public void onError(ChannelHandlerContext ctx, boolean outbound, Throwable cause)

Processes the given error.

Parameters
ctx:ChannelHandlerContext

The context used for communication and buffer allocation if necessary.

outbound:boolean

true if the error was caused by an outbound operation and so the corresponding Promise was failed as well.

cause:Throwable

the error.

resetStreamback to summary
public Future<Void> resetStream(ChannelHandlerContext ctx, int streamId, long errorCode)

Ensure the stream identified by streamId is reset. If our local state does not indicate the stream has been reset yet then a RST_STREAM will be sent to the peer. If our local state indicates the stream has already been reset then the return status will indicate success without sending anything to the peer.

Parameters
ctx:ChannelHandlerContext

The context used for communication and buffer allocation if necessary.

streamId:int

The identifier of the stream to reset.

errorCode:long

Justification as to why this stream is being reset. See Http2Error.

Returns:Future<Void>

Will be considered successful when the connection and stream state has been updated, and a RST_STREAM frame has been sent to the peer. If the stream state has already been updated and a RST_STREAM frame has been sent then the return status may indicate success immediately.