@UnstableApi public class DefaultHttp2FrameReader extends java.lang.Object implements Http2FrameReader, Http2FrameSizePolicy, Http2FrameReader.Configuration
Http2FrameReader
that supports all frame types defined by the HTTP/2 specification.Modifier and Type | Class and Description |
---|---|
protected class |
DefaultHttp2FrameReader.HeadersBlockBuilder
Utility class to help with construction of the headers block that may potentially span
multiple frames.
|
private class |
DefaultHttp2FrameReader.HeadersContinuation
Base class for processing of HEADERS and PUSH_PROMISE header blocks that potentially span
multiple frames.
|
Http2FrameReader.Configuration
Modifier and Type | Field and Description |
---|---|
private Http2Flags |
flags |
private byte |
frameType |
private DefaultHttp2FrameReader.HeadersContinuation |
headersContinuation |
private Http2HeadersDecoder |
headersDecoder |
private int |
maxFrameSize |
private int |
payloadLength |
private boolean |
readError
Once set to
true the value will never change. |
private boolean |
readingHeaders
true = reading headers, false = reading payload. |
private int |
streamId |
Constructor and Description |
---|
DefaultHttp2FrameReader()
Create a new instance.
|
DefaultHttp2FrameReader(boolean validateHeaders)
Create a new instance.
|
DefaultHttp2FrameReader(Http2HeadersDecoder headersDecoder) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this reader and frees any allocated resources.
|
private void |
closeHeadersContinuation() |
Http2FrameReader.Configuration |
configuration()
Get the configuration related elements for this
Http2FrameReader |
Http2FrameSizePolicy |
frameSizePolicy()
Get the
Http2FrameSizePolicy for this Http2FrameReader |
Http2HeadersDecoder.Configuration |
headersConfiguration()
Get the
Http2HeadersDecoder.Configuration for this Http2FrameReader |
private static int |
lengthWithoutTrailingPadding(int readableBytes,
int padding)
The padding parameter consists of the 1 byte pad length field and the trailing padding bytes.
|
int |
maxFrameSize()
Gets the maximum allowed frame size.
|
void |
maxFrameSize(int max)
Sets the maximum allowed frame size.
|
private void |
processHeaderState(ByteBuf in) |
private void |
processPayloadState(ChannelHandlerContext ctx,
ByteBuf in,
Http2FrameListener listener) |
private void |
readContinuationFrame(ByteBuf payload,
Http2FrameListener listener) |
private void |
readDataFrame(ChannelHandlerContext ctx,
ByteBuf payload,
Http2FrameListener listener) |
void |
readFrame(ChannelHandlerContext ctx,
ByteBuf input,
Http2FrameListener listener)
Attempts to read the next frame from the input buffer.
|
private static void |
readGoAwayFrame(ChannelHandlerContext ctx,
ByteBuf payload,
Http2FrameListener listener) |
private void |
readHeadersFrame(ChannelHandlerContext ctx,
ByteBuf payload,
Http2FrameListener listener) |
private int |
readPadding(ByteBuf payload)
If padding is present in the payload, reads the next byte as padding.
|
private void |
readPingFrame(ChannelHandlerContext ctx,
ByteBuf payload,
Http2FrameListener listener) |
private void |
readPriorityFrame(ChannelHandlerContext ctx,
ByteBuf payload,
Http2FrameListener listener) |
private void |
readPushPromiseFrame(ChannelHandlerContext ctx,
ByteBuf payload,
Http2FrameListener listener) |
private void |
readRstStreamFrame(ChannelHandlerContext ctx,
ByteBuf payload,
Http2FrameListener listener) |
private void |
readSettingsFrame(ChannelHandlerContext ctx,
ByteBuf payload,
Http2FrameListener listener) |
private void |
readUnknownFrame(ChannelHandlerContext ctx,
ByteBuf payload,
Http2FrameListener listener) |
private void |
readWindowUpdateFrame(ChannelHandlerContext ctx,
ByteBuf payload,
Http2FrameListener listener) |
private void |
resetHeadersContinuationIfEnd(boolean endOfHeaders) |
private void |
verifyAssociatedWithAStream() |
private void |
verifyContinuationFrame() |
private void |
verifyDataFrame() |
private void |
verifyGoAwayFrame() |
private void |
verifyHeadersFrame() |
private void |
verifyNotProcessingHeaders()
Verify that current state is not processing on header block
|
private void |
verifyPadding(int padding) |
private void |
verifyPayloadLength(int payloadLength) |
private void |
verifyPingFrame() |
private void |
verifyPriorityFrame() |
private void |
verifyPushPromiseFrame() |
private void |
verifyRstStreamFrame() |
private void |
verifySettingsFrame() |
private static void |
verifyStreamOrConnectionId(int streamId,
java.lang.String argumentName) |
private void |
verifyUnknownFrame() |
private void |
verifyWindowUpdateFrame() |
private final Http2HeadersDecoder headersDecoder
private boolean readingHeaders
true
= reading headers, false
= reading payload.private boolean readError
true
the value will never change. This is set to true
if an unrecoverable error which
renders the connection unusable.private byte frameType
private int streamId
private Http2Flags flags
private int payloadLength
private DefaultHttp2FrameReader.HeadersContinuation headersContinuation
private int maxFrameSize
public DefaultHttp2FrameReader()
Header names will be validated.
public DefaultHttp2FrameReader(boolean validateHeaders)
validateHeaders
- true
to validate headers. false
to not validate headers.DefaultHttp2HeadersDecoder(boolean)
public DefaultHttp2FrameReader(Http2HeadersDecoder headersDecoder)
public Http2HeadersDecoder.Configuration headersConfiguration()
Http2FrameReader.Configuration
Http2HeadersDecoder.Configuration
for this Http2FrameReader
headersConfiguration
in interface Http2FrameReader.Configuration
public Http2FrameReader.Configuration configuration()
Http2FrameReader
Http2FrameReader
configuration
in interface Http2FrameReader
public Http2FrameSizePolicy frameSizePolicy()
Http2FrameReader.Configuration
Http2FrameSizePolicy
for this Http2FrameReader
frameSizePolicy
in interface Http2FrameReader.Configuration
public void maxFrameSize(int max) throws Http2Exception
Http2FrameSizePolicy
This value is used to represent
SETTINGS_MAX_FRAME_SIZE. This method should
only be called by Netty (not users) as a result of a receiving a SETTINGS
frame.
maxFrameSize
in interface Http2FrameSizePolicy
Http2Exception
public int maxFrameSize()
Http2FrameSizePolicy
This value is used to represent
SETTINGS_MAX_FRAME_SIZE. The initial value
defined by the RFC is unlimited but enforcing a lower limit is generally permitted.
Http2CodecUtil.DEFAULT_MAX_FRAME_SIZE
can be used as a more conservative default.
maxFrameSize
in interface Http2FrameSizePolicy
public void close()
Http2FrameReader
close
in interface Http2FrameReader
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
private void closeHeadersContinuation()
public void readFrame(ChannelHandlerContext ctx, ByteBuf input, Http2FrameListener listener) throws Http2Exception
Http2FrameReader
readFrame
in interface Http2FrameReader
Http2Exception
private void processHeaderState(ByteBuf in) throws Http2Exception
Http2Exception
private void processPayloadState(ChannelHandlerContext ctx, ByteBuf in, Http2FrameListener listener) throws Http2Exception
Http2Exception
private void verifyDataFrame() throws Http2Exception
Http2Exception
private void verifyHeadersFrame() throws Http2Exception
Http2Exception
private void verifyPriorityFrame() throws Http2Exception
Http2Exception
private void verifyRstStreamFrame() throws Http2Exception
Http2Exception
private void verifySettingsFrame() throws Http2Exception
Http2Exception
private void verifyPushPromiseFrame() throws Http2Exception
Http2Exception
private void verifyPingFrame() throws Http2Exception
Http2Exception
private void verifyGoAwayFrame() throws Http2Exception
Http2Exception
private void verifyWindowUpdateFrame() throws Http2Exception
Http2Exception
private void verifyContinuationFrame() throws Http2Exception
Http2Exception
private void verifyUnknownFrame() throws Http2Exception
Http2Exception
private void readDataFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exception
private void readHeadersFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exception
private void resetHeadersContinuationIfEnd(boolean endOfHeaders)
private void readPriorityFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exception
private void readRstStreamFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exception
private void readSettingsFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exception
private void readPushPromiseFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exception
private void readPingFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exception
private static void readGoAwayFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exception
private void readWindowUpdateFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exception
private void readContinuationFrame(ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exception
private void readUnknownFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exception
private int readPadding(ByteBuf payload)
private void verifyPadding(int padding) throws Http2Exception
Http2Exception
private static int lengthWithoutTrailingPadding(int readableBytes, int padding)
private void verifyNotProcessingHeaders() throws Http2Exception
Http2Exception
- thrown if headersContinuation
is not nullprivate void verifyPayloadLength(int payloadLength) throws Http2Exception
Http2Exception
private void verifyAssociatedWithAStream() throws Http2Exception
Http2Exception
private static void verifyStreamOrConnectionId(int streamId, java.lang.String argumentName) throws Http2Exception
Http2Exception