Top Description Inners Fields Constructors Methods
io.netty.handler.codec.http2

public Class DefaultHttp2FrameReader

extends Object
implements Http2FrameReader, Http2FrameSizePolicy, Configuration
Class Inheritance
All Implemented Interfaces
io.netty.handler.codec.http2.Http2FrameReader.Configuration, io.netty.handler.codec.http2.Http2FrameSizePolicy, io.netty.handler.codec.http2.Http2FrameReader, java.io.Closeable, java.lang.AutoCloseable
Annotations
@UnstableApi
Imports
io.netty.buffer.ByteBuf, .ByteBufAllocator, io.netty.channel.ChannelHandlerContext, io.netty.handler.codec.http2.Http2FrameReader.Configuration, io.netty.util.internal.PlatformDependent, .UnstableApi

A Http2FrameReader that supports all frame types defined by the HTTP/2 specification.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
DefaultHttp2FrameReader.HeadersBlockBuilder

Utility class to help with construction of the headers block that may potentially span multiple frames.

private abstract class
DefaultHttp2FrameReader.HeadersContinuation

Base class for processing of HEADERS and PUSH_PROMISE header blocks that potentially span multiple frames.

Field Summary

Modifier and TypeField and Description
private Http2Flags
private byte
private DefaultHttp2FrameReader.HeadersContinuation
private final Http2HeadersDecoder
private int
private int
private boolean
readError

Once set to true the value will never change.

private boolean
readingHeaders

true = reading headers, false = reading payload.

private int

Constructor Summary

AccessConstructor and Description
public
DefaultHttp2FrameReader()

Create a new instance.

public
DefaultHttp2FrameReader(boolean
true to validate headers. false to not validate headers.
validateHeaders
)

Create a new instance.

public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements io.netty.handler.codec.http2.Http2FrameReader.close.

Closes this reader and frees any allocated resources.
private void
public Http2FrameReader.Configuration
configuration()

Implements io.netty.handler.codec.http2.Http2FrameReader.configuration.

Get the configuration related elements for this Http2FrameReader
public Http2FrameSizePolicy
public Http2HeadersDecoder.Configuration
private static int
lengthWithoutTrailingPadding(int readableBytes, int padding)

The padding parameter consists of the 1 byte pad length field and the trailing padding bytes.

public void
maxFrameSize(int max)

Implements io.netty.handler.codec.http2.Http2FrameSizePolicy.maxFrameSize.

Sets the maximum allowed frame size.
public int
maxFrameSize()

Implements io.netty.handler.codec.http2.Http2FrameSizePolicy.maxFrameSize.

Gets the maximum allowed frame size.
private void
private void
private void
readContinuationFrame(ByteBuf payload, int payloadEndIndex, Http2FrameListener listener)

private void
readDataFrame(ChannelHandlerContext ctx, ByteBuf payload, int payloadEndIndex, Http2FrameListener listener)

public void
readFrame(ChannelHandlerContext ctx, ByteBuf input, Http2FrameListener listener)

Implements io.netty.handler.codec.http2.Http2FrameReader.readFrame.

Attempts to read the next frame from the input buffer.
private static void
readGoAwayFrame(ChannelHandlerContext ctx, ByteBuf payload, int payloadEndIndex, Http2FrameListener listener)

private void
readHeadersFrame(final ChannelHandlerContext ctx, ByteBuf payload, int payloadEndIndex, Http2FrameListener listener)

private int
readPadding(ByteBuf payload)

If padding is present in the payload, reads the next byte as padding.

private void
private void
private void
readPushPromiseFrame(final ChannelHandlerContext ctx, ByteBuf payload, int payloadEndIndex, Http2FrameListener listener)

private void
private void
private void
readUnknownFrame(ChannelHandlerContext ctx, ByteBuf payload, int payloadEndIndex, Http2FrameListener listener)

private void
private void
resetHeadersContinuationIfEnd(boolean endOfHeaders)

private void
private void
private void
private void
private void
private void
verifyNotProcessingHeaders()

Verify that current state is not processing on header block

private void
verifyPadding(int padding)

private void
private void
private void
private void
private void
private static void
verifyStreamOrConnectionId(int streamId, String argumentName)

private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

flagsback to summary
private Http2Flags flags
frameTypeback to summary
private byte frameType
headersContinuationback to summary
private DefaultHttp2FrameReader.HeadersContinuation headersContinuation
headersDecoderback to summary
private final Http2HeadersDecoder headersDecoder
maxFrameSizeback to summary
private int maxFrameSize
payloadLengthback to summary
private int payloadLength
readErrorback to summary
private boolean readError

Once set to true the value will never change. This is set to true if an unrecoverable error which renders the connection unusable.

readingHeadersback to summary
private boolean readingHeaders

true = reading headers, false = reading payload.

streamIdback to summary
private int streamId

Constructor Detail

DefaultHttp2FrameReaderback to summary
public DefaultHttp2FrameReader()

Create a new instance.

Header names will be validated.

DefaultHttp2FrameReaderback to summary
public DefaultHttp2FrameReader(boolean validateHeaders)

Create a new instance.

Parameters
validateHeaders:boolean

true to validate headers. false to not validate headers.

See Also
DefaultHttp2HeadersDecoder(boolean)
DefaultHttp2FrameReaderback to summary
public DefaultHttp2FrameReader(Http2HeadersDecoder headersDecoder)

Method Detail

closeback to summary
public void close()

Implements io.netty.handler.codec.http2.Http2FrameReader.close.

Doc from io.netty.handler.codec.http2.Http2FrameReader.close.

Closes this reader and frees any allocated resources.

Annotations
@Override
closeHeadersContinuationback to summary
private void closeHeadersContinuation()
configurationback to summary
public Http2FrameReader.Configuration configuration()

Implements io.netty.handler.codec.http2.Http2FrameReader.configuration.

Doc from io.netty.handler.codec.http2.Http2FrameReader.configuration.

Get the configuration related elements for this Http2FrameReader

Annotations
@Override
frameSizePolicyback to summary
public Http2FrameSizePolicy frameSizePolicy()

Implements io.netty.handler.codec.http2.Http2FrameReader.Configuration.frameSizePolicy.

Doc from io.netty.handler.codec.http2.Http2FrameReader.Configuration.frameSizePolicy.

Get the Http2FrameSizePolicy for this Http2FrameReader

Annotations
@Override
headersConfigurationback to summary
public Http2HeadersDecoder.Configuration headersConfiguration()

Implements io.netty.handler.codec.http2.Http2FrameReader.Configuration.headersConfiguration.

Doc from io.netty.handler.codec.http2.Http2FrameReader.Configuration.headersConfiguration.

Get the Http2HeadersDecoder.Configuration for this Http2FrameReader

Annotations
@Override
lengthWithoutTrailingPaddingback to summary
private static int lengthWithoutTrailingPadding(int readableBytes, int padding)

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.

maxFrameSizeback to summary
public void maxFrameSize(int max) throws Http2Exception

Implements io.netty.handler.codec.http2.Http2FrameSizePolicy.maxFrameSize.

Doc from io.netty.handler.codec.http2.Http2FrameSizePolicy.maxFrameSize.

Sets 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 SETTINGS frame.

Annotations
@Override
maxFrameSizeback to summary
public int maxFrameSize()

Implements io.netty.handler.codec.http2.Http2FrameSizePolicy.maxFrameSize.

Doc from io.netty.handler.codec.http2.Http2FrameSizePolicy.maxFrameSize.

Gets 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_SIZE can be used as a more conservative default.

Annotations
@Override
processHeaderStateback to summary
private void processHeaderState(ByteBuf in) throws Http2Exception
processPayloadStateback to summary
private void processPayloadState(ChannelHandlerContext ctx, ByteBuf in, Http2FrameListener listener) throws Http2Exception
readContinuationFrameback to summary
private void readContinuationFrame(ByteBuf payload, int payloadEndIndex, Http2FrameListener listener) throws Http2Exception
readDataFrameback to summary
private void readDataFrame(ChannelHandlerContext ctx, ByteBuf payload, int payloadEndIndex, Http2FrameListener listener) throws Http2Exception
readFrameback to summary
public void readFrame(ChannelHandlerContext ctx, ByteBuf input, Http2FrameListener listener) throws Http2Exception

Implements io.netty.handler.codec.http2.Http2FrameReader.readFrame.

Doc from io.netty.handler.codec.http2.Http2FrameReader.readFrame.

Attempts 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.

Annotations
@Override
readGoAwayFrameback to summary
private static void readGoAwayFrame(ChannelHandlerContext ctx, ByteBuf payload, int payloadEndIndex, Http2FrameListener listener) throws Http2Exception
readHeadersFrameback to summary
private void readHeadersFrame(final ChannelHandlerContext ctx, ByteBuf payload, int payloadEndIndex, Http2FrameListener listener) throws Http2Exception
readPaddingback to summary
private int readPadding(ByteBuf payload)

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.

readPingFrameback to summary
private void readPingFrame(ChannelHandlerContext ctx, long data, Http2FrameListener listener) throws Http2Exception
readPriorityFrameback to summary
private void readPriorityFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
readPushPromiseFrameback to summary
private void readPushPromiseFrame(final ChannelHandlerContext ctx, ByteBuf payload, int payloadEndIndex, Http2FrameListener listener) throws Http2Exception
readRstStreamFrameback to summary
private void readRstStreamFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
readSettingsFrameback to summary
private void readSettingsFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
readUnknownFrameback to summary
private void readUnknownFrame(ChannelHandlerContext ctx, ByteBuf payload, int payloadEndIndex, Http2FrameListener listener) throws Http2Exception
readWindowUpdateFrameback to summary
private void readWindowUpdateFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception
resetHeadersContinuationIfEndback to summary
private void resetHeadersContinuationIfEnd(boolean endOfHeaders)
verifyAssociatedWithAStreamback to summary
private void verifyAssociatedWithAStream() throws Http2Exception
verifyContinuationFrameback to summary
private void verifyContinuationFrame() throws Http2Exception
verifyDataFrameback to summary
private void verifyDataFrame() throws Http2Exception
verifyGoAwayFrameback to summary
private void verifyGoAwayFrame() throws Http2Exception
verifyHeadersFrameback to summary
private void verifyHeadersFrame() throws Http2Exception
verifyNotProcessingHeadersback to summary
private void verifyNotProcessingHeaders() throws Http2Exception

Verify that current state is not processing on header block

Exceptions
Http2Exception:
thrown if headersContinuation is not null
verifyPaddingback to summary
private void verifyPadding(int padding) throws Http2Exception
verifyPingFrameback to summary
private void verifyPingFrame() throws Http2Exception
verifyPriorityFrameback to summary
private void verifyPriorityFrame() throws Http2Exception
verifyPushPromiseFrameback to summary
private void verifyPushPromiseFrame() throws Http2Exception
verifyRstStreamFrameback to summary
private void verifyRstStreamFrame() throws Http2Exception
verifySettingsFrameback to summary
private void verifySettingsFrame() throws Http2Exception
verifyStreamOrConnectionIdback to summary
private static void verifyStreamOrConnectionId(int streamId, String argumentName) throws Http2Exception
verifyUnknownFrameback to summary
private void verifyUnknownFrame() throws Http2Exception
verifyWindowUpdateFrameback to summary
private void verifyWindowUpdateFrame() throws Http2Exception
io.netty.handler.codec.http2 back to summary

protected Class DefaultHttp2FrameReader.HeadersBlockBuilder

extends Object
Class Inheritance
  • java.lang.Object
  • io.netty.handler.codec.http2.DefaultHttp2FrameReader.HeadersBlockBuilder

Utility class to help with construction of the headers block that may potentially span multiple frames.

Field Summary

Modifier and TypeField and Description
private ByteBuf

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
pack-priv final void
addFragment(ByteBuf
the fragment of the headers block to be added.
fragment
,
int len, ByteBufAllocator
allocator for new blocks if needed.
alloc
,
boolean
flag indicating whether the current frame is the end of the headers. This is used for an optimization for when the first fragment is the full block. In that case, the buffer is used directly without copying.
endOfHeaders
)

Adds a fragment to the block.

pack-priv void
close()

Closes this builder and frees any resources.

pack-priv Http2Headers
headers()

Builds the headers from the completed headers block.

private void
headerSizeExceeded()

The local header size maximum has been exceeded while accumulating bytes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

headerBlockback to summary
private ByteBuf headerBlock

Constructor Detail

HeadersBlockBuilderback to summary
protected HeadersBlockBuilder()

Method Detail

addFragmentback to summary
pack-priv final void addFragment(ByteBuf fragment, int len, ByteBufAllocator alloc, boolean endOfHeaders) throws Http2Exception

Adds a fragment to the block.

Parameters
fragment:ByteBuf

the fragment of the headers block to be added.

alloc:ByteBufAllocator

allocator for new blocks if needed.

endOfHeaders:boolean

flag indicating whether the current frame is the end of the headers. This is used for an optimization for when the first fragment is the full block. In that case, the buffer is used directly without copying.

closeback to summary
pack-priv void close()

Closes this builder and frees any resources.

headersback to summary
pack-priv Http2Headers headers() throws Http2Exception

Builds the headers from the completed headers block. After this is called, this builder should not be called again.

headerSizeExceededback to summary
private void headerSizeExceeded() throws Http2Exception

The local header size maximum has been exceeded while accumulating bytes.

Exceptions
Http2Exception:
A connection error indicating too much data has been received.
io.netty.handler.codec.http2 back to summary

private abstract Class DefaultHttp2FrameReader.HeadersContinuation

extends Object
Class Inheritance
  • java.lang.Object
  • io.netty.handler.codec.http2.DefaultHttp2FrameReader.HeadersContinuation

Base class for processing of HEADERS and PUSH_PROMISE header blocks that potentially span multiple frames. The implementation of this interface will perform the final callback to the Http2FrameListener once the end of headers is reached.

Field Summary

Modifier and TypeField and Description
private final DefaultHttp2FrameReader.HeadersBlockBuilder

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv final void
close()

Free any allocated resources.

pack-priv abstract int
getStreamId()

Returns the stream for which headers are currently being processed.

pack-priv final DefaultHttp2FrameReader.HeadersBlockBuilder
pack-priv abstract void
processFragment(boolean
whether the fragment is the last in the header block.
endOfHeaders
,
ByteBuf
the fragment of the header block to be added.
fragment
,
int len, Http2FrameListener
the listener to be notified if the header block is completed.
listener
)

Processes the next fragment for the current header block.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

builderback to summary
private final DefaultHttp2FrameReader.HeadersBlockBuilder builder

Constructor Detail

HeadersContinuationback to summary
private HeadersContinuation()

Method Detail

closeback to summary
pack-priv final void close()

Free any allocated resources.

getStreamIdback to summary
pack-priv abstract int getStreamId()

Returns the stream for which headers are currently being processed.

headersBlockBuilderback to summary
pack-priv final DefaultHttp2FrameReader.HeadersBlockBuilder headersBlockBuilder()
processFragmentback to summary
pack-priv abstract void processFragment(boolean endOfHeaders, ByteBuf fragment, int len, Http2FrameListener listener) throws Http2Exception

Processes the next fragment for the current header block.

Parameters
endOfHeaders:boolean

whether the fragment is the last in the header block.

fragment:ByteBuf

the fragment of the header block to be added.

listener:Http2FrameListener

the listener to be notified if the header block is completed.