public final class HelloWorldHttp2Handler extends Http2ConnectionHandler implements Http2FrameListener
ByteToMessageDecoder.Cumulator
ChannelHandler.Sharable
COMPOSITE_CUMULATOR, MERGE_CUMULATOR
限定符和类型 | 方法和说明 |
---|---|
void |
exceptionCaught(ChannelHandlerContext ctx,
java.lang.Throwable cause)
Handles
Http2Exception objects that were thrown from other handlers. |
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 |
onHeadersRead(ChannelHandlerContext ctx,
int streamId,
Http2Headers headers,
int padding,
boolean endOfStream)
Handles an inbound
HEADERS frame. |
void |
onHeadersRead(ChannelHandlerContext ctx,
int streamId,
Http2Headers headers,
int streamDependency,
short weight,
boolean exclusive,
int padding,
boolean endOfStream)
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 |
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. |
void |
userEventTriggered(ChannelHandlerContext ctx,
java.lang.Object evt)
Handles the cleartext HTTP upgrade event.
|
bind, channelActive, channelInactive, channelReadComplete, channelWritabilityChanged, close, closeStream, closeStreamLocal, closeStreamRemote, connect, connection, decode, decoder, deregister, disconnect, encoder, flush, frameWriter, goAway, gracefulShutdownTimeoutMillis, gracefulShutdownTimeoutMillis, handlerAdded, handlerRemoved0, handleServerHeaderDecodeSizeError, isGracefulShutdownComplete, onConnectionError, onError, onHttpClientUpgrade, onHttpServerUpgrade, onStreamError, read, resetStream, write
actualReadableBytes, callDecode, channelRead, decodeLast, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode
channelRegistered, channelUnregistered
ensureNotSharable, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handlerRemoved
public void userEventTriggered(ChannelHandlerContext ctx, java.lang.Object evt) throws java.lang.Exception
userEventTriggered
在接口中 ChannelInboundHandler
userEventTriggered
在类中 ByteToMessageDecoder
java.lang.Exception
public void exceptionCaught(ChannelHandlerContext ctx, java.lang.Throwable cause) throws java.lang.Exception
Http2ConnectionHandler
Http2Exception
objects that were thrown from other handlers. Ignores all other exceptions.exceptionCaught
在接口中 ChannelHandler
exceptionCaught
在接口中 ChannelInboundHandler
exceptionCaught
在类中 Http2ConnectionHandler
java.lang.Exception
public int onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endOfStream)
Http2FrameListener
DATA
frame.onDataRead
在接口中 Http2FrameListener
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.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
.public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endOfStream)
Http2FrameListener
HEADERS
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
在接口中 Http2FrameListener
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).endOfStream
- Indicates whether this is the last frame to be sent from the remote endpoint
for this stream.public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endOfStream)
Http2FrameListener
HEADERS
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
在接口中 Http2FrameListener
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).endOfStream
- Indicates whether this is the last frame to be sent from the remote endpoint
for this stream.public void onPriorityRead(ChannelHandlerContext ctx, int streamId, int streamDependency, short weight, boolean exclusive)
Http2FrameListener
PRIORITY
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
在接口中 Http2FrameListener
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.public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode)
Http2FrameListener
RST_STREAM
frame.onRstStreamRead
在接口中 Http2FrameListener
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.public void onSettingsAckRead(ChannelHandlerContext ctx)
Http2FrameListener
SETTINGS
acknowledgment frame.onSettingsAckRead
在接口中 Http2FrameListener
ctx
- the context from the handler where the frame was read.public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings)
Http2FrameListener
SETTINGS
frame.onSettingsRead
在接口中 Http2FrameListener
ctx
- the context from the handler where the frame was read.settings
- the settings received from the remote endpoint.public void onPingRead(ChannelHandlerContext ctx, long data)
Http2FrameListener
PING
frame.onPingRead
在接口中 Http2FrameListener
ctx
- the context from the handler where the frame was read.data
- the payload of the frame.public void onPingAckRead(ChannelHandlerContext ctx, long data)
Http2FrameListener
PING
acknowledgment.onPingAckRead
在接口中 Http2FrameListener
ctx
- the context from the handler where the frame was read.data
- the payload of the frame.public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promisedStreamId, Http2Headers headers, int padding)
Http2FrameListener
PUSH_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
在接口中 Http2FrameListener
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).public void onGoAwayRead(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData)
Http2FrameListener
GO_AWAY
frame.onGoAwayRead
在接口中 Http2FrameListener
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.public void onWindowUpdateRead(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement)
Http2FrameListener
WINDOW_UPDATE
frame.onWindowUpdateRead
在接口中 Http2FrameListener
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.public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, ByteBuf payload)
Http2FrameListener
onUnknownFrame
在接口中 Http2FrameListener
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.