public final class Http2CodecUtil extends Object
Modifier and Type | Method and Description |
---|---|
static long |
calculateMaxHeaderListSizeGoAway(long maxHeaderListSize)
Calculate the threshold in bytes which should trigger a
GO_AWAY if a set of headers exceeds this amount. |
static ByteBuf |
connectionPrefaceBuf()
Returns a buffer containing the
CONNECTION_PREFACE . |
static Http2Exception |
getEmbeddedHttp2Exception(Throwable cause)
Iteratively looks through the causality chain for the given exception and returns the first
Http2Exception or null if none. |
static void |
headerListSizeExceeded(int streamId,
long maxHeaderListSize,
boolean onDecode)
Results in a RST_STREAM being sent for
streamId due to violating
SETTINGS_MAX_HEADER_LIST_SIZE. |
static void |
headerListSizeExceeded(long maxHeaderListSize)
Results in a GO_AWAY being sent due to violating
SETTINGS_MAX_HEADER_LIST_SIZE in an unrecoverable
manner.
|
static boolean |
isMaxFrameSizeValid(int maxFrameSize)
Indicates whether or not the given value for max frame size falls within the valid range.
|
static boolean |
isOutboundStream(boolean server,
int streamId)
Returns
true if the stream is an outbound stream. |
static boolean |
isStreamIdValid(int streamId)
Returns true if the
streamId is a valid HTTP/2 stream identifier. |
static int |
readUnsignedInt(ByteBuf buf)
Reads a big-endian (31-bit) integer from the buffer.
|
static int |
streamableBytes(StreamByteDistributor.StreamState state)
Calculate the amount of bytes that can be sent by
state . |
static ByteBuf |
toByteBuf(ChannelHandlerContext ctx,
Throwable cause)
Creates a buffer containing the error message from the given exception.
|
static void |
verifyPadding(int padding) |
static void |
writeFrameHeader(ByteBuf out,
int payloadLength,
byte type,
Http2Flags flags,
int streamId)
Writes an HTTP/2 frame header to the output buffer.
|
public static final int CONNECTION_STREAM_ID
public static final int HTTP_UPGRADE_STREAM_ID
public static final CharSequence HTTP_UPGRADE_SETTINGS_HEADER
public static final CharSequence HTTP_UPGRADE_PROTOCOL_NAME
public static final CharSequence TLS_UPGRADE_PROTOCOL_NAME
public static final int PING_FRAME_PAYLOAD_LENGTH
public static final short MAX_UNSIGNED_BYTE
public static final int MAX_PADDING
public static final long MAX_UNSIGNED_INT
public static final int FRAME_HEADER_LENGTH
public static final int SETTING_ENTRY_LENGTH
public static final int PRIORITY_ENTRY_LENGTH
public static final int INT_FIELD_LENGTH
public static final short MAX_WEIGHT
public static final short MIN_WEIGHT
public static final int DATA_FRAME_HEADER_LENGTH
public static final int HEADERS_FRAME_HEADER_LENGTH
public static final int PRIORITY_FRAME_LENGTH
public static final int RST_STREAM_FRAME_LENGTH
public static final int PUSH_PROMISE_FRAME_HEADER_LENGTH
public static final int GO_AWAY_FRAME_HEADER_LENGTH
public static final int WINDOW_UPDATE_FRAME_LENGTH
public static final int CONTINUATION_FRAME_HEADER_LENGTH
public static final char SETTINGS_HEADER_TABLE_SIZE
public static final char SETTINGS_ENABLE_PUSH
public static final char SETTINGS_MAX_CONCURRENT_STREAMS
public static final char SETTINGS_INITIAL_WINDOW_SIZE
public static final char SETTINGS_MAX_FRAME_SIZE
public static final char SETTINGS_MAX_HEADER_LIST_SIZE
public static final int NUM_STANDARD_SETTINGS
public static final long MAX_HEADER_TABLE_SIZE
public static final long MAX_CONCURRENT_STREAMS
public static final int MAX_INITIAL_WINDOW_SIZE
public static final int MAX_FRAME_SIZE_LOWER_BOUND
public static final int MAX_FRAME_SIZE_UPPER_BOUND
public static final long MAX_HEADER_LIST_SIZE
public static final long MIN_HEADER_TABLE_SIZE
public static final long MIN_CONCURRENT_STREAMS
public static final int MIN_INITIAL_WINDOW_SIZE
public static final long MIN_HEADER_LIST_SIZE
public static final int DEFAULT_WINDOW_SIZE
public static final short DEFAULT_PRIORITY_WEIGHT
public static final int DEFAULT_HEADER_TABLE_SIZE
public static final long DEFAULT_HEADER_LIST_SIZE
For any given request, a lower limit than what is advertised MAY be enforced.loophole.
public static final int DEFAULT_MAX_FRAME_SIZE
public static final int SMALLEST_MAX_CONCURRENT_STREAMS
SETTINGS_MAX_CONCURRENT_STREAMS
as
recommended by the HTTP/2 spec.public static final long DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT_MILLIS
public static final int DEFAULT_MAX_QUEUED_CONTROL_FRAMES
public static long calculateMaxHeaderListSizeGoAway(long maxHeaderListSize)
GO_AWAY
if a set of headers exceeds this amount.maxHeaderListSize
- SETTINGS_MAX_HEADER_LIST_SIZE for the local
endpoint.GO_AWAY
if a set of headers exceeds this amount.public static boolean isOutboundStream(boolean server, int streamId)
true
if the stream is an outbound stream.server
- true
if the endpoint is a server, false
otherwise.streamId
- the stream identifierpublic static boolean isStreamIdValid(int streamId)
streamId
is a valid HTTP/2 stream identifier.public static boolean isMaxFrameSizeValid(int maxFrameSize)
public static ByteBuf connectionPrefaceBuf()
CONNECTION_PREFACE
.public static Http2Exception getEmbeddedHttp2Exception(Throwable cause)
Http2Exception
or null
if none.public static ByteBuf toByteBuf(ChannelHandlerContext ctx, Throwable cause)
null
returns an empty buffer.public static int readUnsignedInt(ByteBuf buf)
public static void writeFrameHeader(ByteBuf out, int payloadLength, byte type, Http2Flags flags, int streamId)
public static int streamableBytes(StreamByteDistributor.StreamState state)
state
. The lower bound is 0
.public static void headerListSizeExceeded(int streamId, long maxHeaderListSize, boolean onDecode) throws Http2Exception
streamId
due to violating
SETTINGS_MAX_HEADER_LIST_SIZE.streamId
- The stream ID that was being processed when the exceptional condition occurred.maxHeaderListSize
- The max allowed size for a list of headers in bytes which was exceeded.onDecode
- true
if the exception was encountered during decoder. false
for encode.Http2Exception
- a stream error.public static void headerListSizeExceeded(long maxHeaderListSize) throws Http2Exception
maxHeaderListSize
- The max allowed size for a list of headers in bytes which was exceeded.Http2Exception
- a connection error.public static void verifyPadding(int padding)
Copyright © 2008–2024 The Netty Project. All rights reserved.