Package io.netty.handler.codec.http2
Class DefaultHttp2FrameReader
java.lang.Object
io.netty.handler.codec.http2.DefaultHttp2FrameReader
- All Implemented Interfaces:
Http2FrameReader,Http2FrameReader.Configuration,Http2FrameSizePolicy,Closeable,AutoCloseable
public class DefaultHttp2FrameReader
extends Object
implements Http2FrameReader, Http2FrameSizePolicy, Http2FrameReader.Configuration
A
Http2FrameReader that supports all frame types defined by the HTTP/2 specification.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classUtility class to help with construction of the headers block that may potentially span multiple frames.private classBase class for processing of HEADERS and PUSH_PROMISE header blocks that potentially span multiple frames.Nested classes/interfaces inherited from interface io.netty.handler.codec.http2.Http2FrameReader
Http2FrameReader.Configuration -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Http2Flagsprivate static final intprivate byteprivate final Http2HeadersDecoderprivate intprivate final intprivate intprivate booleanOnce set totruethe value will never change.private booleantrue= reading headers,false= reading payload.private int -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance.DefaultHttp2FrameReader(boolean validateHeaders) Create a new instance.DefaultHttp2FrameReader(Http2HeadersDecoder headersDecoder) DefaultHttp2FrameReader(Http2HeadersDecoder headersDecoder, int maxSmallContinuationFrames) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this reader and frees any allocated resources.private voidGet the configuration related elements for thisHttp2FrameReaderGet theHttp2FrameSizePolicyfor thisHttp2FrameReaderGet theHttp2HeadersDecoder.Configurationfor thisHttp2FrameReaderprivate static intlengthWithoutTrailingPadding(int readableBytes, int padding) The padding parameter consists of the 1 byte pad length field and the trailing padding bytes.intGets the maximum allowed frame size.voidmaxFrameSize(int max) Sets the maximum allowed frame size.private booleanprivate voidprocessPayloadState(ChannelHandlerContext ctx, ByteBuf in, Http2FrameListener listener) private voidreadContinuationFrame(ByteBuf payload, Http2FrameListener listener) private voidreadDataFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) voidreadFrame(ChannelHandlerContext ctx, ByteBuf input, Http2FrameListener listener) Attempts to read the next frame from the input buffer.private voidreadGoAwayFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) private voidreadHeadersFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) private intreadPadding(ByteBuf payload) If padding is present in the payload, reads the next byte as padding.private voidreadPingFrame(ChannelHandlerContext ctx, long data, Http2FrameListener listener) private voidreadPriorityFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) private voidreadPushPromiseFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) private voidreadRstStreamFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) private voidreadSettingsFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) private voidreadUnknownFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) private voidreadWindowUpdateFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) private voidresetHeadersContinuationIfEnd(boolean endOfHeaders) private voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidVerify that current state is not processing on header blockprivate voidprivate voidprivate voidprivate voidprivate voidprivate static voidverifyStreamOrConnectionId(int streamId, String argumentName) private voidprivate void
-
Field Details
-
FRAGMENT_THRESHOLD
private static final int FRAGMENT_THRESHOLD- See Also:
-
headersDecoder
-
readingHeaders
private boolean readingHeaderstrue= reading headers,false= reading payload. -
readError
private boolean readErrorOnce set totruethe value will never change. This is set totrueif an unrecoverable error which renders the connection unusable. -
frameType
private byte frameType -
streamId
private int streamId -
flags
-
payloadLength
private int payloadLength -
headersContinuation
-
maxFrameSize
private int maxFrameSize -
maxSmallContinuationFrames
private final int maxSmallContinuationFrames
-
-
Constructor Details
-
DefaultHttp2FrameReader
public DefaultHttp2FrameReader()Create a new instance.Header names will be validated.
-
DefaultHttp2FrameReader
public DefaultHttp2FrameReader(boolean validateHeaders) Create a new instance.- Parameters:
validateHeaders-trueto validate headers.falseto not validate headers.- See Also:
-
DefaultHttp2FrameReader
-
DefaultHttp2FrameReader
-
-
Method Details
-
headersConfiguration
Description copied from interface:Http2FrameReader.ConfigurationGet theHttp2HeadersDecoder.Configurationfor thisHttp2FrameReader- Specified by:
headersConfigurationin interfaceHttp2FrameReader.Configuration
-
configuration
Description copied from interface:Http2FrameReaderGet the configuration related elements for thisHttp2FrameReader- Specified by:
configurationin interfaceHttp2FrameReader
-
frameSizePolicy
Description copied from interface:Http2FrameReader.ConfigurationGet theHttp2FrameSizePolicyfor thisHttp2FrameReader- Specified by:
frameSizePolicyin interfaceHttp2FrameReader.Configuration
-
maxFrameSize
Description copied from interface:Http2FrameSizePolicySets the maximum allowed frame size. Attempts to write frames longer than this maximum will fail.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
SETTINGSframe.- Specified by:
maxFrameSizein interfaceHttp2FrameSizePolicy- Throws:
Http2Exception
-
maxFrameSize
public int maxFrameSize()Description copied from interface:Http2FrameSizePolicyGets the maximum allowed frame size.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_SIZEcan be used as a more conservative default.- Specified by:
maxFrameSizein interfaceHttp2FrameSizePolicy
-
close
public void close()Description copied from interface:Http2FrameReaderCloses this reader and frees any allocated resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceHttp2FrameReader
-
closeHeadersContinuation
private void closeHeadersContinuation() -
readFrame
public void readFrame(ChannelHandlerContext ctx, ByteBuf input, Http2FrameListener listener) throws Http2Exception Description copied from interface:Http2FrameReaderAttempts to read the next frame from the input buffer. If enough data is available to fully read the frame, notifies the listener of the read frame.- Specified by:
readFramein interfaceHttp2FrameReader- Throws:
Http2Exception
-
preProcessFrame
- Throws:
Http2Exception
-
verifyFrameState
- Throws:
Http2Exception
-
processPayloadState
private void processPayloadState(ChannelHandlerContext ctx, ByteBuf in, Http2FrameListener listener) throws Http2Exception - Throws:
Http2Exception
-
verifyDataFrame
- Throws:
Http2Exception
-
verifyHeadersFrame
- Throws:
Http2Exception
-
verifyPriorityFrame
- Throws:
Http2Exception
-
verifyRstStreamFrame
- Throws:
Http2Exception
-
verifySettingsFrame
- Throws:
Http2Exception
-
verifyPushPromiseFrame
- Throws:
Http2Exception
-
verifyPingFrame
- Throws:
Http2Exception
-
verifyGoAwayFrame
- Throws:
Http2Exception
-
verifyWindowUpdateFrame
- Throws:
Http2Exception
-
verifyContinuationFrame
- Throws:
Http2Exception
-
verifyUnknownFrame
- Throws:
Http2Exception
-
readDataFrame
private void readDataFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception - Throws:
Http2Exception
-
readHeadersFrame
private void readHeadersFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception - Throws:
Http2Exception
-
resetHeadersContinuationIfEnd
private void resetHeadersContinuationIfEnd(boolean endOfHeaders) -
readPriorityFrame
private void readPriorityFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception - Throws:
Http2Exception
-
readRstStreamFrame
private void readRstStreamFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception - Throws:
Http2Exception
-
readSettingsFrame
private void readSettingsFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception - Throws:
Http2Exception
-
readPushPromiseFrame
private void readPushPromiseFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception - Throws:
Http2Exception
-
readPingFrame
private void readPingFrame(ChannelHandlerContext ctx, long data, Http2FrameListener listener) throws Http2Exception - Throws:
Http2Exception
-
readGoAwayFrame
private void readGoAwayFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception - Throws:
Http2Exception
-
readWindowUpdateFrame
private void readWindowUpdateFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception - Throws:
Http2Exception
-
readContinuationFrame
private void readContinuationFrame(ByteBuf payload, Http2FrameListener listener) throws Http2Exception - Throws:
Http2Exception
-
readUnknownFrame
private void readUnknownFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception - Throws:
Http2Exception
-
readPadding
If padding is present in the payload, reads the next byte as padding. The padding also includes the one byte width of the pad length field. Otherwise, returns zero. -
lengthWithoutTrailingPadding
private static int lengthWithoutTrailingPadding(int readableBytes, int padding) throws Http2Exception The padding parameter consists of the 1 byte pad length field and the trailing padding bytes. This method returns the number of readable bytes without the trailing padding.- Throws:
Http2Exception
-
verifyNotProcessingHeaders
Verify that current state is not processing on header block- Throws:
Http2Exception- thrown ifheadersContinuationis not null
-
verifyAssociatedWithAStream
- Throws:
Http2Exception
-
verifyStreamOrConnectionId
private static void verifyStreamOrConnectionId(int streamId, String argumentName) throws Http2Exception - Throws:
Http2Exception
-