public class Http2EventAdapter extends Object implements Http2Connection.Listener, Http2FrameListener
Http2Connection.Listener and Http2FrameListener together to provide
NOOP implementation so inheriting classes can selectively choose which methods to override.| Constructor and Description |
|---|
Http2EventAdapter() |
| Modifier and Type | Method and Description |
|---|---|
int |
onDataRead(ChannelHandlerContext ctx,
int streamId,
ByteBuf data,
int padding,
boolean endOfStream)
Handles an inbound
DATA frame. |
void |
onGoAwayRead(ChannelHandlerContext ctx,
int lastStreamId,
long errorCode,
ByteBuf debugData)
Handles an inbound
GO_AWAY frame. |
void |
onGoAwayReceived(int lastStreamId,
long errorCode,
ByteBuf debugData)
Called when a
GOAWAY was received from the remote endpoint. |
void |
onGoAwaySent(int lastStreamId,
long errorCode,
ByteBuf debugData)
Called when a
GOAWAY frame was sent for the connection. |
void |
onHeadersRead(ChannelHandlerContext ctx,
int streamId,
Http2Headers headers,
int padding,
boolean endStream)
Handles an inbound
HEADERS frame. |
void |
onHeadersRead(ChannelHandlerContext ctx,
int streamId,
Http2Headers headers,
int streamDependency,
short weight,
boolean exclusive,
int padding,
boolean endStream)
Handles an inbound
HEADERS frame with priority information specified. |
void |
onPingAckRead(ChannelHandlerContext ctx,
long data)
Handles an inbound
PING acknowledgment. |
void |
onPingRead(ChannelHandlerContext ctx,
long data)
Handles an inbound
PING frame. |
void |
onPriorityRead(ChannelHandlerContext ctx,
int streamId,
int streamDependency,
short weight,
boolean exclusive)
Handles an inbound
PRIORITY frame. |
void |
onPushPromiseRead(ChannelHandlerContext ctx,
int streamId,
int promisedStreamId,
Http2Headers headers,
int padding)
Handles an inbound
PUSH_PROMISE frame. |
void |
onRstStreamRead(ChannelHandlerContext ctx,
int streamId,
long errorCode)
Handles an inbound
RST_STREAM frame. |
void |
onSettingsAckRead(ChannelHandlerContext ctx)
Handles an inbound
SETTINGS acknowledgment frame. |
void |
onSettingsRead(ChannelHandlerContext ctx,
Http2Settings settings)
Handles an inbound
SETTINGS frame. |
void |
onStreamActive(Http2Stream stream)
Notifies the listener that the given stream was made active (i.e.
|
void |
onStreamAdded(Http2Stream stream)
Notifies the listener that the given stream was added to the connection.
|
void |
onStreamClosed(Http2Stream stream)
Notifies the listener that the given stream is now
CLOSED in both directions and will no longer
be accessible via Http2Connection.forEachActiveStream(Http2StreamVisitor). |
void |
onStreamHalfClosed(Http2Stream stream)
Notifies the listener that the given stream has transitioned from
OPEN to HALF CLOSED. |
void |
onStreamRemoved(Http2Stream stream)
Notifies the listener that the given stream has now been removed from the connection and
will no longer be returned via
Http2Connection.stream(int). |
void |
onUnknownFrame(ChannelHandlerContext ctx,
byte frameType,
int streamId,
Http2Flags flags,
ByteBuf payload)
Handler for a frame not defined by the HTTP/2 spec.
|
void |
onWindowUpdateRead(ChannelHandlerContext ctx,
int streamId,
int windowSizeIncrement)
Handles an inbound
WINDOW_UPDATE frame. |
public int onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endOfStream) throws Http2Exception
Http2FrameListenerDATA frame.onDataRead in interface Http2FrameListenerctx - the context from the handler where the frame was read.streamId - the subject stream for the frame.data - payload buffer for the frame. This buffer will be released by the codec.padding - additional bytes that should be added to obscure the true content size. Must be between 0 and
256 (inclusive).endOfStream - Indicates whether this is the last frame to be sent from the remote endpoint for this stream.WINDOW_UPDATE). Returning a value equal to the length of data + padding will effectively
opt-out of application-level flow control for this frame. Returning a value less than the length of data
+ padding will defer the returning of the processed bytes, which the application must later return via
Http2LocalFlowController.consumeBytes(Http2Stream, int). The returned value must
be >= 0 and <= data.readableBytes() + padding.Http2Exceptionpublic void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream) throws Http2Exception
Http2FrameListenerHEADERS frame.
Only one of the following methods will be called for each HEADERS frame sequence.
One will be called when the END_HEADERS flag has been received.
Http2FrameListener.onHeadersRead(ChannelHandlerContext, int, Http2Headers, int, boolean)Http2FrameListener.onHeadersRead(ChannelHandlerContext, int, Http2Headers, int, short, boolean, int, boolean)Http2FrameListener.onPushPromiseRead(ChannelHandlerContext, int, int, Http2Headers, int)
To say it another way; the Http2Headers will contain all of the headers
for the current message exchange step (additional queuing is not necessary).
onHeadersRead in interface Http2FrameListenerctx - the context from the handler where the frame was read.streamId - the subject stream for the frame.headers - the received headers.padding - additional bytes that should be added to obscure the true content size. Must be between 0 and
256 (inclusive).endStream - Indicates whether this is the last frame to be sent from the remote endpoint
for this stream.Http2Exceptionpublic void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endStream) throws Http2Exception
Http2FrameListenerHEADERS frame with priority information specified.
Only called if END_HEADERS encountered.
Only one of the following methods will be called for each HEADERS frame sequence.
One will be called when the END_HEADERS flag has been received.
Http2FrameListener.onHeadersRead(ChannelHandlerContext, int, Http2Headers, int, boolean)Http2FrameListener.onHeadersRead(ChannelHandlerContext, int, Http2Headers, int, short, boolean, int, boolean)Http2FrameListener.onPushPromiseRead(ChannelHandlerContext, int, int, Http2Headers, int)
To say it another way; the Http2Headers will contain all of the headers
for the current message exchange step (additional queuing is not necessary).
onHeadersRead in interface Http2FrameListenerctx - the context from the handler where the frame was read.streamId - the subject stream for the frame.headers - the received headers.streamDependency - the stream on which this stream depends, or 0 if dependent on the
connection.weight - the new weight for the stream.exclusive - whether or not the stream should be the exclusive dependent of its parent.padding - additional bytes that should be added to obscure the true content size. Must be between 0 and
256 (inclusive).endStream - Indicates whether this is the last frame to be sent from the remote endpoint
for this stream.Http2Exceptionpublic void onPriorityRead(ChannelHandlerContext ctx, int streamId, int streamDependency, short weight, boolean exclusive) throws Http2Exception
Http2FrameListenerPRIORITY frame.
Note that is it possible to have this method called and no stream object exist for either
streamId, streamDependency, or both. This is because the PRIORITY frame can be
sent/received when streams are in the CLOSED state.
onPriorityRead in interface Http2FrameListenerctx - the context from the handler where the frame was read.streamId - the subject stream for the frame.streamDependency - the stream on which this stream depends, or 0 if dependent on the
connection.weight - the new weight for the stream.exclusive - whether or not the stream should be the exclusive dependent of its parent.Http2Exceptionpublic void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode) throws Http2Exception
Http2FrameListenerRST_STREAM frame.onRstStreamRead in interface Http2FrameListenerctx - the context from the handler where the frame was read.streamId - the stream that is terminating.errorCode - the error code identifying the type of failure.Http2Exceptionpublic void onSettingsAckRead(ChannelHandlerContext ctx) throws Http2Exception
Http2FrameListenerSETTINGS acknowledgment frame.onSettingsAckRead in interface Http2FrameListenerctx - the context from the handler where the frame was read.Http2Exceptionpublic void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) throws Http2Exception
Http2FrameListenerSETTINGS frame.onSettingsRead in interface Http2FrameListenerctx - the context from the handler where the frame was read.settings - the settings received from the remote endpoint.Http2Exceptionpublic void onPingRead(ChannelHandlerContext ctx, long data) throws Http2Exception
Http2FrameListenerPING frame.onPingRead in interface Http2FrameListenerctx - the context from the handler where the frame was read.data - the payload of the frame.Http2Exceptionpublic void onPingAckRead(ChannelHandlerContext ctx, long data) throws Http2Exception
Http2FrameListenerPING acknowledgment.onPingAckRead in interface Http2FrameListenerctx - the context from the handler where the frame was read.data - the payload of the frame.Http2Exceptionpublic void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promisedStreamId, Http2Headers headers, int padding) throws Http2Exception
Http2FrameListenerPUSH_PROMISE frame. Only called if END_HEADERS encountered.
Promised requests MUST be authoritative, cacheable, and safe. See [RFC 7540], Section 8.2.
Only one of the following methods will be called for each HEADERS frame sequence.
One will be called when the END_HEADERS flag has been received.
Http2FrameListener.onHeadersRead(ChannelHandlerContext, int, Http2Headers, int, boolean)Http2FrameListener.onHeadersRead(ChannelHandlerContext, int, Http2Headers, int, short, boolean, int, boolean)Http2FrameListener.onPushPromiseRead(ChannelHandlerContext, int, int, Http2Headers, int)
To say it another way; the Http2Headers will contain all of the headers
for the current message exchange step (additional queuing is not necessary).
onPushPromiseRead in interface Http2FrameListenerctx - the context from the handler where the frame was read.streamId - the stream the frame was sent on.promisedStreamId - the ID of the promised stream.headers - the received headers.padding - additional bytes that should be added to obscure the true content size. Must be between 0 and
256 (inclusive).Http2Exceptionpublic void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData) throws Http2Exception
Http2FrameListenerGO_AWAY frame.onGoAwayRead in interface Http2FrameListenerctx - the context from the handler where the frame was read.lastStreamId - the last known stream of the remote endpoint.errorCode - the error code, if abnormal closure.debugData - application-defined debug data. If this buffer needs to be retained by the
listener they must make a copy.Http2Exceptionpublic void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement) throws Http2Exception
Http2FrameListenerWINDOW_UPDATE frame.onWindowUpdateRead in interface Http2FrameListenerctx - the context from the handler where the frame was read.streamId - the stream the frame was sent on.windowSizeIncrement - the increased number of bytes of the remote endpoint's flow
control window.Http2Exceptionpublic void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, ByteBuf payload) throws Http2Exception
Http2FrameListeneronUnknownFrame in interface Http2FrameListenerctx - the context from the handler where the frame was read.frameType - the frame type from the HTTP/2 header.streamId - the stream the frame was sent on.flags - the flags in the frame header.payload - the payload of the frame.Http2Exceptionpublic void onStreamAdded(Http2Stream stream)
Http2Connection.ListenerOPEN or HALF CLOSED).
If a RuntimeException is thrown it will be logged and not propagated.
Throwing from this method is not supported and is considered a programming error.
onStreamAdded in interface Http2Connection.Listenerpublic void onStreamActive(Http2Stream stream)
Http2Connection.ListenerOPEN or HALF CLOSED).
If a RuntimeException is thrown it will be logged and not propagated.
Throwing from this method is not supported and is considered a programming error.
onStreamActive in interface Http2Connection.Listenerpublic void onStreamHalfClosed(Http2Stream stream)
Http2Connection.ListenerOPEN to HALF CLOSED.
This method will not be called until a state transition occurs from when
Http2Connection.Listener.onStreamActive(Http2Stream) was called.
The stream can be inspected to determine which side is HALF CLOSED.
If a RuntimeException is thrown it will be logged and not propagated.
Throwing from this method is not supported and is considered a programming error.
onStreamHalfClosed in interface Http2Connection.Listenerpublic void onStreamClosed(Http2Stream stream)
Http2Connection.ListenerCLOSED in both directions and will no longer
be accessible via Http2Connection.forEachActiveStream(Http2StreamVisitor).
If a RuntimeException is thrown it will be logged and not propagated.
Throwing from this method is not supported and is considered a programming error.
onStreamClosed in interface Http2Connection.Listenerpublic void onStreamRemoved(Http2Stream stream)
Http2Connection.ListenerHttp2Connection.stream(int). The connection may
maintain inactive streams for some time before removing them.
If a RuntimeException is thrown it will be logged and not propagated.
Throwing from this method is not supported and is considered a programming error.
onStreamRemoved in interface Http2Connection.Listenerpublic void onGoAwaySent(int lastStreamId,
long errorCode,
ByteBuf debugData)
Http2Connection.ListenerGOAWAY frame was sent for the connection.
If a RuntimeException is thrown it will be logged and not propagated.
Throwing from this method is not supported and is considered a programming error.
onGoAwaySent in interface Http2Connection.ListenerlastStreamId - the last known stream of the remote endpoint.errorCode - the error code, if abnormal closure.debugData - application-defined debug data.public void onGoAwayReceived(int lastStreamId,
long errorCode,
ByteBuf debugData)
Http2Connection.ListenerGOAWAY was received from the remote endpoint. This event handler duplicates Http2FrameListener.onGoAwayRead(io.netty.channel.ChannelHandlerContext, int, long, ByteBuf)
but is added here in order to simplify application logic for handling GOAWAY in a uniform way. An
application should generally not handle both events, but if it does this method is called second, after
notifying the Http2FrameListener.
If a RuntimeException is thrown it will be logged and not propagated.
Throwing from this method is not supported and is considered a programming error.
onGoAwayReceived in interface Http2Connection.ListenerlastStreamId - the last known stream of the remote endpoint.errorCode - the error code, if abnormal closure.debugData - application-defined debug data.Copyright © 2008–2025 The Netty Project. All rights reserved.