public class StreamingInboundHttp2ToHttpAdapter
extends io.netty.handler.codec.http2.Http2EventAdapter
Http2EventAdapter that allows streaming requests for servers and responses for clients by
establishing a processor that emits chunks as HttpContent.
This implementation does not buffer the data. If you need data buffering a FlowControlHandler
can be placed after this implementation so that downstream handlers can control flow.
Based on code in InboundHttp2ToHttpAdapter.| Modifier and Type | Field and Description |
|---|---|
protected io.netty.handler.codec.http2.Http2Connection |
connection |
protected boolean |
validateHttpHeaders |
| Constructor and Description |
|---|
StreamingInboundHttp2ToHttpAdapter(io.netty.handler.codec.http2.Http2Connection connection,
int maxContentLength)
Default constructor.
|
StreamingInboundHttp2ToHttpAdapter(io.netty.handler.codec.http2.Http2Connection connection,
int maxContentLength,
boolean validateHttpHeaders,
boolean propagateSettings)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
fireChannelRead(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.HttpContent msg,
io.netty.handler.codec.http2.Http2Stream stream)
fire a channel read event.
|
protected void |
fireChannelRead(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.HttpMessage msg,
io.netty.handler.codec.http2.Http2Stream stream)
fire a channel read event.
|
protected io.netty.handler.codec.http.HttpMessage |
getMessage(io.netty.handler.codec.http2.Http2Stream stream)
Get the
FullHttpMessage associated with stream. |
protected io.netty.handler.codec.http.HttpMessage |
newMessage(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http2.Http2Stream stream,
io.netty.handler.codec.http2.Http2Headers headers,
boolean validateHttpHeaders)
Create a new
FullHttpMessage based upon the current connection parameters. |
int |
onDataRead(io.netty.channel.ChannelHandlerContext ctx,
int streamId,
io.netty.buffer.ByteBuf data,
int padding,
boolean endOfStream) |
void |
onHeadersRead(io.netty.channel.ChannelHandlerContext ctx,
int streamId,
io.netty.handler.codec.http2.Http2Headers headers,
int padding,
boolean endOfStream) |
void |
onHeadersRead(io.netty.channel.ChannelHandlerContext ctx,
int streamId,
io.netty.handler.codec.http2.Http2Headers headers,
int streamDependency,
short weight,
boolean exclusive,
int padding,
boolean endOfStream) |
void |
onPushPromiseRead(io.netty.channel.ChannelHandlerContext ctx,
int streamId,
int promisedStreamId,
io.netty.handler.codec.http2.Http2Headers headers,
int padding) |
void |
onRstStreamRead(io.netty.channel.ChannelHandlerContext ctx,
int streamId,
long errorCode) |
protected void |
onRstStreamRead(io.netty.handler.codec.http2.Http2Stream stream,
io.netty.handler.codec.http.HttpMessage msg)
Called if a
RST_STREAM is received but we have some data for that stream. |
void |
onSettingsRead(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http2.Http2Settings settings) |
void |
onStreamRemoved(io.netty.handler.codec.http2.Http2Stream stream) |
protected io.netty.handler.codec.http.HttpMessage |
processHeadersBegin(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http2.Http2Stream stream,
io.netty.handler.codec.http2.Http2Headers headers,
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(io.netty.handler.codec.http2.Http2Stream stream,
io.netty.handler.codec.http.HttpMessage message)
Make
message be the state associated with stream. |
protected void |
removeMessage(io.netty.handler.codec.http2.Http2Stream stream)
The stream is out of scope for the HTTP message flow and will no longer be tracked.
|
protected final io.netty.handler.codec.http2.Http2Connection connection
protected final boolean validateHttpHeaders
public StreamingInboundHttp2ToHttpAdapter(io.netty.handler.codec.http2.Http2Connection connection,
int maxContentLength,
boolean validateHttpHeaders,
boolean propagateSettings)
connection - The connectionmaxContentLength - The max content lengthvalidateHttpHeaders - Whether to validate headerspropagateSettings - Whether to propagate settingspublic StreamingInboundHttp2ToHttpAdapter(io.netty.handler.codec.http2.Http2Connection connection,
int maxContentLength)
connection - The connectionmaxContentLength - The max content lengthprotected final void removeMessage(io.netty.handler.codec.http2.Http2Stream stream)
stream - The stream to remove associated state withprotected final io.netty.handler.codec.http.HttpMessage getMessage(io.netty.handler.codec.http2.Http2Stream stream)
FullHttpMessage associated with stream.stream - The stream to get the associated state fromFullHttpMessage associated with stream.protected final void putMessage(io.netty.handler.codec.http2.Http2Stream stream,
io.netty.handler.codec.http.HttpMessage 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(io.netty.handler.codec.http2.Http2Stream stream)
onStreamRemoved in interface io.netty.handler.codec.http2.Http2Connection.ListeneronStreamRemoved in class io.netty.handler.codec.http2.Http2EventAdapterprotected void fireChannelRead(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.HttpContent msg,
io.netty.handler.codec.http2.Http2Stream stream)
ctx - The context to fire the event onmsg - The message to sendstream - the stream of the message which is being firedprotected void fireChannelRead(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.HttpMessage msg,
io.netty.handler.codec.http2.Http2Stream stream)
ctx - The context to fire the event onmsg - The message to sendstream - the stream of the message which is being firedprotected io.netty.handler.codec.http.HttpMessage newMessage(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http2.Http2Stream stream,
io.netty.handler.codec.http2.Http2Headers headers,
boolean validateHttpHeaders)
throws io.netty.handler.codec.http2.Http2Exception
FullHttpMessage based upon the current connection parameters.ctx - The channel contextstream - The stream to create a message forheaders - The headers associated with streamvalidateHttpHeaders - true to validate HTTP headers in the http-codecfalse not to validate HTTP headers in the http-codecStreamedHttpMessageio.netty.handler.codec.http2.Http2Exception - thrown if an error occurs creating the requestprotected io.netty.handler.codec.http.HttpMessage processHeadersBegin(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http2.Http2Stream stream,
io.netty.handler.codec.http2.Http2Headers headers,
boolean allowAppend,
boolean appendToTrailer)
throws io.netty.handler.codec.http2.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 processallowAppend - 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.io.netty.handler.codec.http2.Http2Exception - If the stream id is not in the correct state to process the headers requestpublic int onDataRead(io.netty.channel.ChannelHandlerContext ctx,
int streamId,
io.netty.buffer.ByteBuf data,
int padding,
boolean endOfStream)
throws io.netty.handler.codec.http2.Http2Exception
onDataRead in interface io.netty.handler.codec.http2.Http2FrameListeneronDataRead in class io.netty.handler.codec.http2.Http2EventAdapterio.netty.handler.codec.http2.Http2Exceptionpublic void onHeadersRead(io.netty.channel.ChannelHandlerContext ctx,
int streamId,
io.netty.handler.codec.http2.Http2Headers headers,
int padding,
boolean endOfStream)
throws io.netty.handler.codec.http2.Http2Exception
onHeadersRead in interface io.netty.handler.codec.http2.Http2FrameListeneronHeadersRead in class io.netty.handler.codec.http2.Http2EventAdapterio.netty.handler.codec.http2.Http2Exceptionpublic void onHeadersRead(io.netty.channel.ChannelHandlerContext ctx,
int streamId,
io.netty.handler.codec.http2.Http2Headers headers,
int streamDependency,
short weight,
boolean exclusive,
int padding,
boolean endOfStream)
throws io.netty.handler.codec.http2.Http2Exception
onHeadersRead in interface io.netty.handler.codec.http2.Http2FrameListeneronHeadersRead in class io.netty.handler.codec.http2.Http2EventAdapterio.netty.handler.codec.http2.Http2Exceptionpublic void onRstStreamRead(io.netty.channel.ChannelHandlerContext ctx,
int streamId,
long errorCode)
onRstStreamRead in interface io.netty.handler.codec.http2.Http2FrameListeneronRstStreamRead in class io.netty.handler.codec.http2.Http2EventAdapterpublic void onPushPromiseRead(io.netty.channel.ChannelHandlerContext ctx,
int streamId,
int promisedStreamId,
io.netty.handler.codec.http2.Http2Headers headers,
int padding)
throws io.netty.handler.codec.http2.Http2Exception
onPushPromiseRead in interface io.netty.handler.codec.http2.Http2FrameListeneronPushPromiseRead in class io.netty.handler.codec.http2.Http2EventAdapterio.netty.handler.codec.http2.Http2Exceptionpublic void onSettingsRead(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http2.Http2Settings settings)
throws io.netty.handler.codec.http2.Http2Exception
onSettingsRead in interface io.netty.handler.codec.http2.Http2FrameListeneronSettingsRead in class io.netty.handler.codec.http2.Http2EventAdapterio.netty.handler.codec.http2.Http2Exceptionprotected void onRstStreamRead(io.netty.handler.codec.http2.Http2Stream stream,
io.netty.handler.codec.http.HttpMessage msg)
RST_STREAM is received but we have some data for that stream.stream - The streammsg - The message