@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.ConfigurationHttp2HeadersDecoder.Configuration for this Http2FrameReaderheadersConfiguration in interface Http2FrameReader.Configurationpublic Http2FrameReader.Configuration configuration()
Http2FrameReaderHttp2FrameReaderconfiguration in interface Http2FrameReaderpublic Http2FrameSizePolicy frameSizePolicy()
Http2FrameReader.ConfigurationHttp2FrameSizePolicy for this Http2FrameReaderframeSizePolicy in interface Http2FrameReader.Configurationpublic 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 Http2FrameSizePolicyHttp2Exceptionpublic 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 Http2FrameSizePolicypublic void close()
Http2FrameReaderclose in interface Http2FrameReaderclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableprivate void closeHeadersContinuation()
public void readFrame(ChannelHandlerContext ctx, ByteBuf input, Http2FrameListener listener) throws Http2Exception
Http2FrameReaderreadFrame in interface Http2FrameReaderHttp2Exceptionprivate void processHeaderState(ByteBuf in) throws Http2Exception
Http2Exceptionprivate void processPayloadState(ChannelHandlerContext ctx, ByteBuf in, Http2FrameListener listener) throws Http2Exception
Http2Exceptionprivate void verifyDataFrame()
throws Http2Exception
Http2Exceptionprivate void verifyHeadersFrame()
throws Http2Exception
Http2Exceptionprivate void verifyPriorityFrame()
throws Http2Exception
Http2Exceptionprivate void verifyRstStreamFrame()
throws Http2Exception
Http2Exceptionprivate void verifySettingsFrame()
throws Http2Exception
Http2Exceptionprivate void verifyPushPromiseFrame()
throws Http2Exception
Http2Exceptionprivate void verifyPingFrame()
throws Http2Exception
Http2Exceptionprivate void verifyGoAwayFrame()
throws Http2Exception
Http2Exceptionprivate void verifyWindowUpdateFrame()
throws Http2Exception
Http2Exceptionprivate void verifyContinuationFrame()
throws Http2Exception
Http2Exceptionprivate void verifyUnknownFrame()
throws Http2Exception
Http2Exceptionprivate void readDataFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exceptionprivate void readHeadersFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exceptionprivate void resetHeadersContinuationIfEnd(boolean endOfHeaders)
private void readPriorityFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exceptionprivate void readRstStreamFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exceptionprivate void readSettingsFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exceptionprivate void readPushPromiseFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exceptionprivate void readPingFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exceptionprivate static void readGoAwayFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exceptionprivate void readWindowUpdateFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exceptionprivate void readContinuationFrame(ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exceptionprivate void readUnknownFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
Http2Exceptionprivate int readPadding(ByteBuf payload)
private void verifyPadding(int padding)
throws Http2Exception
Http2Exceptionprivate 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
Http2Exceptionprivate void verifyAssociatedWithAStream()
throws Http2Exception
Http2Exceptionprivate static void verifyStreamOrConnectionId(int streamId,
java.lang.String argumentName)
throws Http2Exception
Http2Exception