public class InboundHttp2ToHttpAdapter extends Http2EventAdapter
See HttpToHttp2ConnectionHandler to get translation from HTTP/1.x objects to HTTP/2 frames for writes.
| Modifier and Type | Class and Description |
|---|---|
static class |
InboundHttp2ToHttpAdapter.Builder |
| Modifier and Type | Field and Description |
|---|---|
protected Http2Connection |
connection |
protected IntObjectMap<FullHttpMessage> |
messageMap |
protected boolean |
validateHttpHeaders |
| Modifier | Constructor and Description |
|---|---|
protected |
InboundHttp2ToHttpAdapter(InboundHttp2ToHttpAdapter.Builder builder) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
fireChannelRead(ChannelHandlerContext ctx,
FullHttpMessage msg,
int streamId)
Set final headers and fire a channel read event
|
protected FullHttpMessage |
newMessage(int streamId,
Http2Headers headers,
boolean validateHttpHeaders)
Create a new
FullHttpMessage based upon the current connection parameters |
int |
onDataRead(ChannelHandlerContext ctx,
int streamId,
ByteBuf data,
int padding,
boolean endOfStream)
Handles an inbound
DATA 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 |
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 |
onSettingsRead(ChannelHandlerContext ctx,
Http2Settings settings)
Handles an inbound SETTINGS frame.
|
protected FullHttpMessage |
processHeadersBegin(ChannelHandlerContext ctx,
int streamId,
Http2Headers headers,
boolean endOfStream,
boolean allowAppend,
boolean appendToTrailer)
Provides translation between HTTP/2 and HTTP header objects while ensuring the stream
is in a valid state for additional headers.
|
protected void |
removeMessage(int streamId)
The streamId is out of scope for the HTTP message flow and will no longer be tracked
|
void |
streamRemoved(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). |
goingAway, onGoAwayRead, onPingAckRead, onPingRead, onPriorityRead, onSettingsAckRead, onUnknownFrame, onWeightChanged, onWindowUpdateRead, priorityTreeParentChanged, priorityTreeParentChanging, streamActive, streamAdded, streamHalfClosed, streamInactiveprotected final Http2Connection connection
protected final boolean validateHttpHeaders
protected final IntObjectMap<FullHttpMessage> messageMap
protected InboundHttp2ToHttpAdapter(InboundHttp2ToHttpAdapter.Builder builder)
protected void removeMessage(int streamId)
streamId - The stream id to remove associated state withpublic void streamRemoved(Http2Stream stream)
Http2Connection.ListenerHttp2Connection.stream(int). The connection may
maintain inactive streams for some time before removing them.streamRemoved in interface Http2Connection.ListenerstreamRemoved in class Http2EventAdapterprotected void fireChannelRead(ChannelHandlerContext ctx, FullHttpMessage msg, int streamId)
ctx - The context to fire the event onmsg - The message to sendstreamId - the streamId of the message which is being firedprotected FullHttpMessage newMessage(int streamId, Http2Headers headers, boolean validateHttpHeaders) throws Http2Exception
FullHttpMessage based upon the current connection parametersstreamId - The stream id to create a message forheaders - The headers associated with streamIdvalidateHttpHeaders - true to validate HTTP headers in the http-codecfalse not to validate HTTP headers in the http-codecHttp2Exceptionprotected FullHttpMessage processHeadersBegin(ChannelHandlerContext ctx, int streamId, Http2Headers headers, boolean endOfStream, boolean allowAppend, boolean appendToTrailer) throws Http2Exception
ctx - The context for which this message has been received.
Used to send informational header if detected.streamId - The stream id the headers apply toheaders - The headers to processendOfStream - true if the streamId has received the end of stream flagallowAppend - true if headers will be appended if the stream already exists.false and the stream already exists this method returns null.appendToTrailer - true if a message streamId already exists then the headers
should be added to the trailing headers.false then appends will be done to the initial headers.streamId. null if
allowAppend is false and the stream already exists.Http2Exception - If the stream id is not in the correct state to process the headers requestpublic int onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endOfStream) throws Http2Exception
Http2FrameListenerDATA frame.onDataRead in interface Http2FrameListeneronDataRead in class Http2EventAdapterctx - 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 - the number of padding bytes found at the end of the frame.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
Http2InboundFlowState#returnProcessedBytes(ChannelHandlerContext, int). The
returned value must be >= 0 and <= data.readableBytes() +
padding.Http2Exceptionpublic void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endOfStream) throws Http2Exception
Http2FrameListenerOnly 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 Http2FrameListeneronHeadersRead in class Http2EventAdapterctx - the context from the handler where the frame was read.streamId - the subject stream for the frame.headers - the received headers.padding - the number of padding bytes found at the end of the frame.endOfStream - 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 endOfStream) throws Http2Exception
Http2FrameListenerOnly 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 Http2FrameListeneronHeadersRead in class Http2EventAdapterctx - 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 - the number of padding bytes found at the end of the frame.endOfStream - Indicates whether this is the last frame to be sent from the remote endpoint
for this stream.Http2Exceptionpublic void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode) throws Http2Exception
Http2FrameListeneronRstStreamRead in interface Http2FrameListeneronRstStreamRead in class Http2EventAdapterctx - 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 onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promisedStreamId, Http2Headers headers, int padding) throws Http2Exception
Http2FrameListener
Promised requests MUST be cacheable
(see [RFC7231], Section 4.2.3) and
MUST be safe (see [RFC7231], Section 4.2.1).
If these conditions do not hold the application MUST throw a Http2Exception.StreamException with
error type Http2Error.PROTOCOL_ERROR.
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 Http2FrameListeneronPushPromiseRead in class Http2EventAdapterctx - 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 - the number of padding bytes found at the end of the frame.Http2Exceptionpublic void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) throws Http2Exception
Http2FrameListeneronSettingsRead in interface Http2FrameListeneronSettingsRead in class Http2EventAdapterctx - the context from the handler where the frame was read.settings - the settings received from the remote endpoint.Http2ExceptionCopyright © 2008–2015 The Netty Project. All rights reserved.