- java.lang.Object
-
- io.netty5.handler.codec.http2.Http2FrameAdapter
-
- All Implemented Interfaces:
Http2FrameListener
@UnstableApi public class Http2FrameAdapter extends Object implements Http2FrameListener
Convenience class that provides no-op implementations for all methods ofHttp2FrameListener
.
-
-
Constructor Summary
Constructors Constructor Description Http2FrameAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
onDataRead(ChannelHandlerContext ctx, int streamId, Buffer data, int padding, boolean endOfStream)
Handles an inboundDATA
frame.void
onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, Buffer debugData)
Handles an inboundGO_AWAY
frame.void
onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream)
Handles an inboundHEADERS
frame.void
onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endStream)
Handles an inboundHEADERS
frame with priority information specified.void
onPingAckRead(ChannelHandlerContext ctx, long data)
Handles an inboundPING
acknowledgment.void
onPingRead(ChannelHandlerContext ctx, long data)
Handles an inboundPING
frame.void
onPriorityRead(ChannelHandlerContext ctx, int streamId, int streamDependency, short weight, boolean exclusive)
Handles an inboundPRIORITY
frame.void
onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promisedStreamId, Http2Headers headers, int padding)
Handles an inboundPUSH_PROMISE
frame.void
onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode)
Handles an inboundRST_STREAM
frame.void
onSettingsAckRead(ChannelHandlerContext ctx)
Handles an inboundSETTINGS
acknowledgment frame.void
onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings)
Handles an inboundSETTINGS
frame.void
onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, Buffer payload)
Handler for a frame not defined by the HTTP/2 spec.void
onWindowUpdateRead(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement)
Handles an inboundWINDOW_UPDATE
frame.
-
-
-
Method Detail
-
onDataRead
public int onDataRead(ChannelHandlerContext ctx, int streamId, Buffer data, int padding, boolean endOfStream) throws Http2Exception
Description copied from interface:Http2FrameListener
Handles an inboundDATA
frame.- Specified by:
onDataRead
in interfaceHttp2FrameListener
- Parameters:
ctx
- 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.- Returns:
- the number of bytes that have been processed by the application. The returned bytes are used by the
inbound flow controller to determine the appropriate time to expand the inbound flow control window (i.e. send
WINDOW_UPDATE
). Returning a value equal to the length ofdata
+padding
will effectively opt-out of application-level flow control for this frame. Returning a value less than the length ofdata
+padding
will defer the returning of the processed bytes, which the application must later return viaHttp2LocalFlowController.consumeBytes(Http2Stream, int)
. The returned value must be >=0
and <=data.readableBytes()
+padding
. - Throws:
Http2Exception
-
onHeadersRead
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream) throws Http2Exception
Description copied from interface:Http2FrameListener
Handles an inboundHEADERS
frame.Only one of the following methods will be called for each
HEADERS
frame sequence. One will be called when theEND_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).- Specified by:
onHeadersRead
in interfaceHttp2FrameListener
- Parameters:
ctx
- 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.- Throws:
Http2Exception
-
onHeadersRead
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endStream) throws Http2Exception
Description copied from interface:Http2FrameListener
Handles an inboundHEADERS
frame with priority information specified. Only called ifEND_HEADERS
encountered.Only one of the following methods will be called for each
HEADERS
frame sequence. One will be called when theEND_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).- Specified by:
onHeadersRead
in interfaceHttp2FrameListener
- Parameters:
ctx
- 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.- Throws:
Http2Exception
-
onPriorityRead
public void onPriorityRead(ChannelHandlerContext ctx, int streamId, int streamDependency, short weight, boolean exclusive) throws Http2Exception
Description copied from interface:Http2FrameListener
Handles an inboundPRIORITY
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 thePRIORITY
frame can be sent/received when streams are in theCLOSED
state.- Specified by:
onPriorityRead
in interfaceHttp2FrameListener
- Parameters:
ctx
- 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.- Throws:
Http2Exception
-
onRstStreamRead
public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode) throws Http2Exception
Description copied from interface:Http2FrameListener
Handles an inboundRST_STREAM
frame.- Specified by:
onRstStreamRead
in interfaceHttp2FrameListener
- Parameters:
ctx
- 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.- Throws:
Http2Exception
-
onSettingsAckRead
public void onSettingsAckRead(ChannelHandlerContext ctx) throws Http2Exception
Description copied from interface:Http2FrameListener
Handles an inboundSETTINGS
acknowledgment frame.- Specified by:
onSettingsAckRead
in interfaceHttp2FrameListener
- Parameters:
ctx
- the context from the handler where the frame was read.- Throws:
Http2Exception
-
onSettingsRead
public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) throws Http2Exception
Description copied from interface:Http2FrameListener
Handles an inboundSETTINGS
frame.- Specified by:
onSettingsRead
in interfaceHttp2FrameListener
- Parameters:
ctx
- the context from the handler where the frame was read.settings
- the settings received from the remote endpoint.- Throws:
Http2Exception
-
onPingRead
public void onPingRead(ChannelHandlerContext ctx, long data) throws Http2Exception
Description copied from interface:Http2FrameListener
Handles an inboundPING
frame.- Specified by:
onPingRead
in interfaceHttp2FrameListener
- Parameters:
ctx
- the context from the handler where the frame was read.data
- the payload of the frame.- Throws:
Http2Exception
-
onPingAckRead
public void onPingAckRead(ChannelHandlerContext ctx, long data) throws Http2Exception
Description copied from interface:Http2FrameListener
Handles an inboundPING
acknowledgment.- Specified by:
onPingAckRead
in interfaceHttp2FrameListener
- Parameters:
ctx
- the context from the handler where the frame was read.data
- the payload of the frame.- Throws:
Http2Exception
-
onPushPromiseRead
public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promisedStreamId, Http2Headers headers, int padding) throws Http2Exception
Description copied from interface:Http2FrameListener
Handles an inboundPUSH_PROMISE
frame. Only called ifEND_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 theEND_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).- Specified by:
onPushPromiseRead
in interfaceHttp2FrameListener
- Parameters:
ctx
- 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).- Throws:
Http2Exception
-
onGoAwayRead
public void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, Buffer debugData) throws Http2Exception
Description copied from interface:Http2FrameListener
Handles an inboundGO_AWAY
frame.- Specified by:
onGoAwayRead
in interfaceHttp2FrameListener
- Parameters:
ctx
- 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.- Throws:
Http2Exception
-
onWindowUpdateRead
public void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement) throws Http2Exception
Description copied from interface:Http2FrameListener
Handles an inboundWINDOW_UPDATE
frame.- Specified by:
onWindowUpdateRead
in interfaceHttp2FrameListener
- Parameters:
ctx
- 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.- Throws:
Http2Exception
-
onUnknownFrame
public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, Buffer payload)
Description copied from interface:Http2FrameListener
Handler for a frame not defined by the HTTP/2 spec.- Specified by:
onUnknownFrame
in interfaceHttp2FrameListener
- Parameters:
ctx
- 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.
-
-