Top Description Fields Constructors Methods
io.netty5.handler.codec.http2

public Class DefaultHttp2FrameWriter

extends Object
implements Http2FrameWriter, Http2FrameSizePolicy, Configuration
Class Inheritance
All Implemented Interfaces
io.netty5.handler.codec.http2.Http2FrameWriter.Configuration, io.netty5.handler.codec.http2.Http2FrameSizePolicy, io.netty5.handler.codec.http2.Http2FrameWriter, java.io.Closeable, java.lang.AutoCloseable, io.netty5.handler.codec.http2.Http2DataWriter
Annotations
@UnstableApi
Imports
io.netty5.buffer.Buffer, .BufferAllocator, io.netty5.channel.ChannelHandlerContext, io.netty5.handler.codec.http2.Http2CodecUtil.SimpleChannelPromiseAggregator, .Http2FrameWriter.Configuration, .Http2HeadersEncoder.SensitivityDetector, io.netty5.handler.codec.http2.headers.Http2Headers, io.netty5.util.concurrent.Future, io.netty5.util.internal.UnstableApi

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

Field Summary

Modifier and TypeField and Description
private final Http2HeadersEncoder
private int
private static final String
private static final String
private static final Buffer
ZERO_BUFFER

This buffer is allocated to the maximum size of the padding field, and filled with zeros.

Constructor Summary

AccessConstructor and Description
public
public
public
DefaultHttp2FrameWriter(Http2HeadersEncoder.SensitivityDetector headersSensitivityDetector, boolean ignoreMaxHeaderListSize)

public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements io.netty5.handler.codec.http2.Http2FrameWriter.close.

Closes this writer and frees any allocated resources.
public Http2FrameWriter.Configuration
configuration()

Implements io.netty5.handler.codec.http2.Http2FrameWriter.configuration.

Get the configuration related elements for this Http2FrameWriter
public Http2FrameSizePolicy
public Http2HeadersEncoder.Configuration
public void
maxFrameSize(int max)

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

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

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

Gets the maximum allowed frame size.
private static int
paddingBytes(int padding)

Returns the number of padding bytes that should be appended to the end of a frame.

private static void
verifyErrorCode(long errorCode)

private static void
verifyStreamId(int streamId, String argumentName)

private static void
verifyStreamOrConnectionId(int streamId, String argumentName)

private static void
verifyWeight(short weight)

private static void
verifyWindowSizeIncrement(int windowSizeIncrement)

private Future<Void>
writeContinuationFrames(ChannelHandlerContext ctx, int streamId, Buffer headerBlock, Http2CodecUtil.SimpleChannelPromiseAggregator promiseAggregator)

Writes as many continuation frames as needed until padding and headerBlock are consumed.

public Future<Void>
writeData(ChannelHandlerContext
the context to use for writing.
ctx
,
int
the stream for which to send the frame.
streamId
,
Buffer
the payload of the frame. This will be released by this method.
data
,
int
additional bytes that should be added to obscure the true content size. Must be between 0 and 256 (inclusive). A 1 byte padding is encoded as just the pad length field with value 0. A 256 byte padding is encoded as the pad length field with value 255 and 255 padding bytes appended to the end of the frame.
padding
,
boolean
indicates if this is the last frame to be sent for the stream.
endStream
)

Implements io.netty5.handler.codec.http2.Http2DataWriter.writeData.

Writes a DATA frame to the remote endpoint.
public Future<Void>
writeFrame(ChannelHandlerContext
the context to use for writing.
ctx
,
byte
the frame type identifier.
frameType
,
int
the stream for which to send the frame.
streamId
,
Http2Flags
the flags to write for this frame.
flags
,
Buffer
the payload to write for this frame. This will be released by this method.
payload
)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeFrame.

Generic write method for any HTTP/2 frame.
public Future<Void>
writeGoAway(ChannelHandlerContext
the context to use for writing.
ctx
,
int
the last known stream of this endpoint.
lastStreamId
,
long
the error code, if the connection was abnormally terminated.
errorCode
,
Buffer
application-defined debug data. This will be released by this method.
debugData
)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeGoAway.

Writes a GO_AWAY frame to the remote endpoint.
public Future<Void>
writeHeaders(ChannelHandlerContext
the context to use for writing.
ctx
,
int
the stream for which to send the frame.
streamId
,
Http2Headers
the headers to be sent.
headers
,
int
additional bytes that should be added to obscure the true content size. Must be between 0 and 256 (inclusive).
padding
,
boolean
indicates if this is the last frame to be sent for the stream.
endStream
)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeHeaders.

Writes a HEADERS frame to the remote endpoint.
public Future<Void>
writeHeaders(ChannelHandlerContext
the context to use for writing.
ctx
,
int
the stream for which to send the frame.
streamId
,
Http2Headers
the headers to be sent.
headers
,
int
the stream on which this stream should depend, or 0 if it should depend on the connection.
streamDependency
,
short
the weight for this stream.
weight
,
boolean
whether this stream should be the exclusive dependant of its parent.
exclusive
,
int
additional bytes that should be added to obscure the true content size. Must be between 0 and 256 (inclusive).
padding
,
boolean
indicates if this is the last frame to be sent for the stream.
endStream
)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeHeaders.

Writes a HEADERS frame with priority specified to the remote endpoint.
private Future<Void>
writeHeadersInternal(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream, boolean hasPriority, int streamDependency, short weight, boolean exclusive)

private static void
writePaddingLength(Buffer buf, int padding)

public Future<Void>
writePing(ChannelHandlerContext
the context to use for writing.
ctx
,
boolean
indicates whether this is an ack of a PING frame previously received from the remote endpoint.
ack
,
long
the payload of the frame.
data
)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writePing.

Writes a PING frame to the remote endpoint.
public Future<Void>
writePriority(ChannelHandlerContext
the context to use for writing.
ctx
,
int
the stream for which to send the frame.
streamId
,
int
the stream on which this stream should depend, or 0 if it should depend on the connection.
streamDependency
,
short
the weight for this stream.
weight
,
boolean
whether this stream should be the exclusive dependant of its parent.
exclusive
)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writePriority.

Writes a PRIORITY frame to the remote endpoint.
public Future<Void>
writePushPromise(ChannelHandlerContext
the context to use for writing.
ctx
,
int
the stream for which to send the frame.
streamId
,
int
the ID of the promised stream.
promisedStreamId
,
Http2Headers
the headers to be sent.
headers
,
int
additional bytes that should be added to obscure the true content size. Must be between 0 and 256 (inclusive).
padding
)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writePushPromise.

Writes a PUSH_PROMISE frame to the remote endpoint.
public Future<Void>
writeRstStream(ChannelHandlerContext
the context to use for writing.
ctx
,
int
the stream for which to send the frame.
streamId
,
long
the error code indicating the nature of the failure.
errorCode
)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeRstStream.

Writes a RST_STREAM frame to the remote endpoint.
public Future<Void>
writeSettings(ChannelHandlerContext
the context to use for writing.
ctx
,
Http2Settings
the settings to be sent.
settings
)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeSettings.

Writes a SETTINGS frame to the remote endpoint.
public Future<Void>
writeSettingsAck(ChannelHandlerContext
the context to use for writing.
ctx
)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeSettingsAck.

Writes a SETTINGS acknowledgment to the remote endpoint.
public Future<Void>
writeWindowUpdate(ChannelHandlerContext
the context to use for writing.
ctx
,
int
the stream for which to send the frame.
streamId
,
int
the number of bytes by which the local inbound flow control window is increasing.
windowSizeIncrement
)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeWindowUpdate.

Writes a WINDOW_UPDATE frame to the remote endpoint.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

headersEncoderback to summary
private final Http2HeadersEncoder headersEncoder
maxFrameSizeback to summary
private int maxFrameSize
STREAM_DEPENDENCYback to summary
private static final String STREAM_DEPENDENCY
STREAM_IDback to summary
private static final String STREAM_ID
ZERO_BUFFERback to summary
private static final Buffer ZERO_BUFFER

This buffer is allocated to the maximum size of the padding field, and filled with zeros. When padding is needed it can be taken as a slice of this buffer. Users should call Buffer#copy(int, int, boolean) before using their slice.

Constructor Detail

DefaultHttp2FrameWriterback to summary
public DefaultHttp2FrameWriter()
DefaultHttp2FrameWriterback to summary
public DefaultHttp2FrameWriter(Http2HeadersEncoder.SensitivityDetector headersSensitivityDetector)
DefaultHttp2FrameWriterback to summary
public DefaultHttp2FrameWriter(Http2HeadersEncoder.SensitivityDetector headersSensitivityDetector, boolean ignoreMaxHeaderListSize)
DefaultHttp2FrameWriterback to summary
public DefaultHttp2FrameWriter(Http2HeadersEncoder headersEncoder)

Method Detail

closeback to summary
public void close()

Implements io.netty5.handler.codec.http2.Http2FrameWriter.close.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.close.

Closes this writer and frees any allocated resources.

Annotations
@Override
configurationback to summary
public Http2FrameWriter.Configuration configuration()

Implements io.netty5.handler.codec.http2.Http2FrameWriter.configuration.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.configuration.

Get the configuration related elements for this Http2FrameWriter

Annotations
@Override
frameSizePolicyback to summary
public Http2FrameSizePolicy frameSizePolicy()

Implements io.netty5.handler.codec.http2.Http2FrameWriter.Configuration.frameSizePolicy.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.Configuration.frameSizePolicy.

Get the Http2FrameSizePolicy for this Http2FrameWriter

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

Implements io.netty5.handler.codec.http2.Http2FrameWriter.Configuration.headersConfiguration.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.Configuration.headersConfiguration.

Get the Http2HeadersEncoder.Configuration for this Http2FrameWriter

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

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

Doc from io.netty5.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.netty5.handler.codec.http2.Http2FrameSizePolicy.maxFrameSize.

Doc from io.netty5.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
paddingBytesback to summary
private static int paddingBytes(int padding)

Returns the number of padding bytes that should be appended to the end of a frame.

verifyErrorCodeback to summary
private static void verifyErrorCode(long errorCode)
verifyStreamIdback to summary
private static void verifyStreamId(int streamId, String argumentName)
verifyStreamOrConnectionIdback to summary
private static void verifyStreamOrConnectionId(int streamId, String argumentName)
verifyWeightback to summary
private static void verifyWeight(short weight)
verifyWindowSizeIncrementback to summary
private static void verifyWindowSizeIncrement(int windowSizeIncrement)
writeContinuationFramesback to summary
private Future<Void> writeContinuationFrames(ChannelHandlerContext ctx, int streamId, Buffer headerBlock, Http2CodecUtil.SimpleChannelPromiseAggregator promiseAggregator)

Writes as many continuation frames as needed until padding and headerBlock are consumed.

writeDataback to summary
public Future<Void> writeData(ChannelHandlerContext ctx, int streamId, Buffer data, int padding, boolean endStream)

Implements io.netty5.handler.codec.http2.Http2DataWriter.writeData.

Doc from io.netty5.handler.codec.http2.Http2DataWriter.writeData.

Writes a DATA frame to the remote endpoint. This will result in one or more frames being written to the context.

Parameters
ctx:ChannelHandlerContext

the context to use for writing.

streamId:int

the stream for which to send the frame.

data:Buffer

the payload of the frame. This will be released by this method.

padding:int

additional bytes that should be added to obscure the true content size. Must be between 0 and 256 (inclusive). A 1 byte padding is encoded as just the pad length field with value 0. A 256 byte padding is encoded as the pad length field with value 255 and 255 padding bytes appended to the end of the frame.

endStream:boolean

indicates if this is the last frame to be sent for the stream.

Returns:Future<Void>

the future for the write.

Annotations
@Override
writeFrameback to summary
public Future<Void> writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, Buffer payload)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeFrame.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.writeFrame.

Generic write method for any HTTP/2 frame. This allows writing of non-standard frames.

Parameters
ctx:ChannelHandlerContext

the context to use for writing.

frameType:byte

the frame type identifier.

streamId:int

the stream for which to send the frame.

flags:Http2Flags

the flags to write for this frame.

payload:Buffer

the payload to write for this frame. This will be released by this method.

Returns:Future<Void>

the future for the write.

Annotations
@Override
writeGoAwayback to summary
public Future<Void> writeGoAway(ChannelHandlerContext ctx, int lastStreamId, long errorCode, Buffer debugData)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeGoAway.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.writeGoAway.

Writes a GO_AWAY frame to the remote endpoint.

Parameters
ctx:ChannelHandlerContext

the context to use for writing.

lastStreamId:int

the last known stream of this endpoint.

errorCode:long

the error code, if the connection was abnormally terminated.

debugData:Buffer

application-defined debug data. This will be released by this method.

Returns:Future<Void>

the future for the write.

Annotations
@Override
writeHeadersback to summary
public Future<Void> writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeHeaders.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.writeHeaders.

Writes a HEADERS frame to the remote endpoint.

Parameters
ctx:ChannelHandlerContext

the context to use for writing.

streamId:int

the stream for which to send the frame.

headers:Http2Headers

the headers to be sent.

padding:int

additional bytes that should be added to obscure the true content size. Must be between 0 and 256 (inclusive).

endStream:boolean

indicates if this is the last frame to be sent for the stream.

Returns:Future<Void>

the future for the write. Section 10.5.1 states the following:

The header block MUST be processed to ensure a consistent connection state, unless the connection is closed.
If this call has modified the HPACK header state you MUST throw a connection error.

If this call has NOT modified the HPACK header state you are free to throw a stream error.

Annotations
@Override
writeHeadersback to summary
public Future<Void> writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endStream)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeHeaders.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.writeHeaders.

Writes a HEADERS frame with priority specified to the remote endpoint.

Parameters
ctx:ChannelHandlerContext

the context to use for writing.

streamId:int

the stream for which to send the frame.

headers:Http2Headers

the headers to be sent.

streamDependency:int

the stream on which this stream should depend, or 0 if it should depend on the connection.

weight:short

the weight for this stream.

exclusive:boolean

whether this stream should be the exclusive dependant of its parent.

padding:int

additional bytes that should be added to obscure the true content size. Must be between 0 and 256 (inclusive).

endStream:boolean

indicates if this is the last frame to be sent for the stream.

Returns:Future<Void>

the future for the write. Section 10.5.1 states the following:

The header block MUST be processed to ensure a consistent connection state, unless the connection is closed.
If this call has modified the HPACK header state you MUST throw a connection error.

If this call has NOT modified the HPACK header state you are free to throw a stream error.

Annotations
@Override
writeHeadersInternalback to summary
private Future<Void> writeHeadersInternal(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream, boolean hasPriority, int streamDependency, short weight, boolean exclusive)
writePaddingLengthback to summary
private static void writePaddingLength(Buffer buf, int padding)
writePingback to summary
public Future<Void> writePing(ChannelHandlerContext ctx, boolean ack, long data)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writePing.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.writePing.

Writes a PING frame to the remote endpoint.

Parameters
ctx:ChannelHandlerContext

the context to use for writing.

ack:boolean

indicates whether this is an ack of a PING frame previously received from the remote endpoint.

data:long

the payload of the frame.

Returns:Future<Void>

the future for the write.

Annotations
@Override
writePriorityback to summary
public Future<Void> writePriority(ChannelHandlerContext ctx, int streamId, int streamDependency, short weight, boolean exclusive)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writePriority.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.writePriority.

Writes a PRIORITY frame to the remote endpoint.

Parameters
ctx:ChannelHandlerContext

the context to use for writing.

streamId:int

the stream for which to send the frame.

streamDependency:int

the stream on which this stream should depend, or 0 if it should depend on the connection.

weight:short

the weight for this stream.

exclusive:boolean

whether this stream should be the exclusive dependant of its parent.

Returns:Future<Void>

the future for the write.

Annotations
@Override
writePushPromiseback to summary
public Future<Void> writePushPromise(ChannelHandlerContext ctx, int streamId, int promisedStreamId, Http2Headers headers, int padding)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writePushPromise.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.writePushPromise.

Writes a PUSH_PROMISE frame to the remote endpoint.

Parameters
ctx:ChannelHandlerContext

the context to use for writing.

streamId:int

the stream for which to send the frame.

promisedStreamId:int

the ID of the promised stream.

headers:Http2Headers

the headers to be sent.

padding:int

additional bytes that should be added to obscure the true content size. Must be between 0 and 256 (inclusive).

Returns:Future<Void>

the future for the write. Section 10.5.1 states the following:

The header block MUST be processed to ensure a consistent connection state, unless the connection is closed.
If this call has modified the HPACK header state you MUST throw a connection error.

If this call has NOT modified the HPACK header state you are free to throw a stream error.

Annotations
@Override
writeRstStreamback to summary
public Future<Void> writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeRstStream.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.writeRstStream.

Writes a RST_STREAM frame to the remote endpoint.

Parameters
ctx:ChannelHandlerContext

the context to use for writing.

streamId:int

the stream for which to send the frame.

errorCode:long

the error code indicating the nature of the failure.

Returns:Future<Void>

the future for the write.

Annotations
@Override
writeSettingsback to summary
public Future<Void> writeSettings(ChannelHandlerContext ctx, Http2Settings settings)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeSettings.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.writeSettings.

Writes a SETTINGS frame to the remote endpoint.

Parameters
ctx:ChannelHandlerContext

the context to use for writing.

settings:Http2Settings

the settings to be sent.

Returns:Future<Void>

the future for the write.

Annotations
@Override
writeSettingsAckback to summary
public Future<Void> writeSettingsAck(ChannelHandlerContext ctx)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeSettingsAck.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.writeSettingsAck.

Writes a SETTINGS acknowledgment to the remote endpoint.

Parameters
ctx:ChannelHandlerContext

the context to use for writing.

Returns:Future<Void>

the future for the write.

Annotations
@Override
writeWindowUpdateback to summary
public Future<Void> writeWindowUpdate(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement)

Implements io.netty5.handler.codec.http2.Http2FrameWriter.writeWindowUpdate.

Doc from io.netty5.handler.codec.http2.Http2FrameWriter.writeWindowUpdate.

Writes a WINDOW_UPDATE frame to the remote endpoint.

Parameters
ctx:ChannelHandlerContext

the context to use for writing.

streamId:int

the stream for which to send the frame.

windowSizeIncrement:int

the number of bytes by which the local inbound flow control window is increasing.

Returns:Future<Void>

the future for the write.

Annotations
@Override