@UnstableApi public class InboundHttp2ToHttpAdapter extends Http2EventAdapter
See HttpToHttp2ConnectionHandler
to get translation from HTTP/1.x objects to HTTP/2 frames for writes.
Modifier and Type | Field and Description |
---|---|
protected Http2Connection |
connection |
protected boolean |
validateHttpHeaders |
Modifier | Constructor and Description |
---|---|
protected |
InboundHttp2ToHttpAdapter(Http2Connection connection,
int maxContentLength,
boolean validateHttpHeaders,
boolean propagateSettings) |
Modifier and Type | Method and Description |
---|---|
protected void |
fireChannelRead(ChannelHandlerContext ctx,
FullHttpMessage msg,
boolean release,
Http2Stream stream)
Set final headers and fire a channel read event
|
protected FullHttpMessage |
getMessage(Http2Stream stream)
Get the
FullHttpMessage associated with stream . |
protected FullHttpMessage |
newMessage(Http2Stream stream,
Http2Headers headers,
boolean validateHttpHeaders,
ByteBufAllocator alloc)
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. |
protected void |
onRstStreamRead(Http2Stream stream,
FullHttpMessage msg)
Called if a
RST_STREAM is received but we have some data for that stream. |
void |
onSettingsRead(ChannelHandlerContext ctx,
Http2Settings settings)
Handles an inbound
SETTINGS frame. |
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) . |
protected FullHttpMessage |
processHeadersBegin(ChannelHandlerContext ctx,
Http2Stream stream,
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 |
putMessage(Http2Stream stream,
FullHttpMessage message)
Make
message be the state associated with stream . |
protected void |
removeMessage(Http2Stream stream,
boolean release)
The stream is out of scope for the HTTP message flow and will no longer be tracked
|
onGoAwayRead, onGoAwayReceived, onGoAwaySent, onPingAckRead, onPingRead, onPriorityRead, onSettingsAckRead, onStreamActive, onStreamAdded, onStreamClosed, onStreamHalfClosed, onUnknownFrame, onWindowUpdateRead
protected final Http2Connection connection
protected final boolean validateHttpHeaders
protected InboundHttp2ToHttpAdapter(Http2Connection connection, int maxContentLength, boolean validateHttpHeaders, boolean propagateSettings)
protected final void removeMessage(Http2Stream stream, boolean release)
stream
- The stream to remove associated state withrelease
- true
to call release on the value if it is present. false
to not call release.protected final FullHttpMessage getMessage(Http2Stream stream)
FullHttpMessage
associated with stream
.stream
- The stream to get the associated state fromFullHttpMessage
associated with stream
.protected final void putMessage(Http2Stream stream, FullHttpMessage message)
message
be the state associated with stream
.stream
- The stream which message
is associated with.message
- The message which contains the HTTP semantics.public void onStreamRemoved(Http2Stream stream)
Http2Connection.Listener
Http2Connection.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.Listener
onStreamRemoved
in class Http2EventAdapter
protected void fireChannelRead(ChannelHandlerContext ctx, FullHttpMessage msg, boolean release, Http2Stream stream)
ctx
- The context to fire the event onmsg
- The message to sendrelease
- true
to call release on the value if it is present. false
to not call release.stream
- the stream of the message which is being firedprotected FullHttpMessage newMessage(Http2Stream stream, Http2Headers headers, boolean validateHttpHeaders, ByteBufAllocator alloc) throws Http2Exception
FullHttpMessage
based upon the current connection parametersstream
- The stream to create a message forheaders
- The headers associated with stream
validateHttpHeaders
- true
to validate HTTP headers in the http-codecfalse
not to validate HTTP headers in the http-codecalloc
- The ByteBufAllocator
to use to generate the content of the messageHttp2Exception
protected FullHttpMessage processHeadersBegin(ChannelHandlerContext ctx, Http2Stream stream, 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.stream
- The stream the headers
apply toheaders
- The headers to processendOfStream
- true
if the stream
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 stream
already exists then the headers
should be added to the trailing headers.false
then appends will be done to the initial headers.stream
. 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
Http2FrameListener
DATA
frame.onDataRead
in interface Http2FrameListener
onDataRead
in class Http2EventAdapter
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
.Http2Exception
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endOfStream) throws Http2Exception
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
in interface Http2FrameListener
onHeadersRead
in class Http2EventAdapter
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.Http2Exception
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endOfStream) throws Http2Exception
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
in interface Http2FrameListener
onHeadersRead
in class Http2EventAdapter
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.Http2Exception
public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode) throws Http2Exception
Http2FrameListener
RST_STREAM
frame.onRstStreamRead
in interface Http2FrameListener
onRstStreamRead
in class Http2EventAdapter
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.Http2Exception
public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promisedStreamId, Http2Headers headers, int padding) throws Http2Exception
Http2FrameListener
PUSH_PROMISE
frame. Only called if END_HEADERS
encountered.
Promised requests MUST be authoritative, cacheable, and safe. See [RFC http2], 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 Http2FrameListener
onPushPromiseRead
in class Http2EventAdapter
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).Http2Exception
public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) throws Http2Exception
Http2FrameListener
SETTINGS
frame.onSettingsRead
in interface Http2FrameListener
onSettingsRead
in class Http2EventAdapter
ctx
- the context from the handler where the frame was read.settings
- the settings received from the remote endpoint.Http2Exception
protected void onRstStreamRead(Http2Stream stream, FullHttpMessage msg)
RST_STREAM
is received but we have some data for that stream.Copyright © 2008–2017 The Netty Project. All rights reserved.