public class DefaultHttp2FrameWriter extends Object implements Http2FrameWriter, Http2FrameSizePolicy, Http2FrameWriter.Configuration
Http2FrameWriter
that supports all frame types defined by the HTTP/2 specification.Http2FrameWriter.Configuration
Constructor and Description |
---|
DefaultHttp2FrameWriter() |
DefaultHttp2FrameWriter(Http2HeadersEncoder.SensitivityDetector headersSensitivityDetector) |
DefaultHttp2FrameWriter(Http2HeadersEncoder.SensitivityDetector headersSensitivityDetector,
boolean ignoreMaxHeaderListSize) |
DefaultHttp2FrameWriter(Http2HeadersEncoder headersEncoder) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this writer and frees any allocated resources.
|
Http2FrameWriter.Configuration |
configuration()
Get the configuration related elements for this
Http2FrameWriter |
Http2FrameSizePolicy |
frameSizePolicy()
Get the
Http2FrameSizePolicy for this Http2FrameWriter |
Http2HeadersEncoder.Configuration |
headersConfiguration()
Get the
Http2HeadersEncoder.Configuration for this Http2FrameWriter |
int |
maxFrameSize()
Gets the maximum allowed frame size.
|
void |
maxFrameSize(int max)
Sets the maximum allowed frame size.
|
ChannelFuture |
writeData(ChannelHandlerContext ctx,
int streamId,
ByteBuf data,
int padding,
boolean endStream,
ChannelPromise promise)
Writes a
DATA frame to the remote endpoint. |
ChannelFuture |
writeFrame(ChannelHandlerContext ctx,
byte frameType,
int streamId,
Http2Flags flags,
ByteBuf payload,
ChannelPromise promise)
Generic write method for any HTTP/2 frame.
|
ChannelFuture |
writeGoAway(ChannelHandlerContext ctx,
int lastStreamId,
long errorCode,
ByteBuf debugData,
ChannelPromise promise)
Writes a GO_AWAY frame to the remote endpoint.
|
ChannelFuture |
writeHeaders(ChannelHandlerContext ctx,
int streamId,
Http2Headers headers,
int padding,
boolean endStream,
ChannelPromise promise)
Writes a HEADERS frame to the remote endpoint.
|
ChannelFuture |
writeHeaders(ChannelHandlerContext ctx,
int streamId,
Http2Headers headers,
int streamDependency,
short weight,
boolean exclusive,
int padding,
boolean endStream,
ChannelPromise promise)
Writes a HEADERS frame with priority specified to the remote endpoint.
|
ChannelFuture |
writePing(ChannelHandlerContext ctx,
boolean ack,
long data,
ChannelPromise promise)
Writes a PING frame to the remote endpoint.
|
ChannelFuture |
writePriority(ChannelHandlerContext ctx,
int streamId,
int streamDependency,
short weight,
boolean exclusive,
ChannelPromise promise)
Writes a PRIORITY frame to the remote endpoint.
|
ChannelFuture |
writePushPromise(ChannelHandlerContext ctx,
int streamId,
int promisedStreamId,
Http2Headers headers,
int padding,
ChannelPromise promise)
Writes a PUSH_PROMISE frame to the remote endpoint.
|
ChannelFuture |
writeRstStream(ChannelHandlerContext ctx,
int streamId,
long errorCode,
ChannelPromise promise)
Writes a RST_STREAM frame to the remote endpoint.
|
ChannelFuture |
writeSettings(ChannelHandlerContext ctx,
Http2Settings settings,
ChannelPromise promise)
Writes a SETTINGS frame to the remote endpoint.
|
ChannelFuture |
writeSettingsAck(ChannelHandlerContext ctx,
ChannelPromise promise)
Writes a SETTINGS acknowledgment to the remote endpoint.
|
ChannelFuture |
writeWindowUpdate(ChannelHandlerContext ctx,
int streamId,
int windowSizeIncrement,
ChannelPromise promise)
Writes a WINDOW_UPDATE frame to the remote endpoint.
|
public DefaultHttp2FrameWriter()
public DefaultHttp2FrameWriter(Http2HeadersEncoder.SensitivityDetector headersSensitivityDetector)
public DefaultHttp2FrameWriter(Http2HeadersEncoder.SensitivityDetector headersSensitivityDetector, boolean ignoreMaxHeaderListSize)
public DefaultHttp2FrameWriter(Http2HeadersEncoder headersEncoder)
headersEncoder
- will be closed if it implements Closeable
public Http2FrameWriter.Configuration configuration()
Http2FrameWriter
Http2FrameWriter
configuration
in interface Http2FrameWriter
public Http2HeadersEncoder.Configuration headersConfiguration()
Http2FrameWriter.Configuration
Http2HeadersEncoder.Configuration
for this Http2FrameWriter
headersConfiguration
in interface Http2FrameWriter.Configuration
public Http2FrameSizePolicy frameSizePolicy()
Http2FrameWriter.Configuration
Http2FrameSizePolicy
for this Http2FrameWriter
frameSizePolicy
in interface Http2FrameWriter.Configuration
public 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 Http2FrameSizePolicy
Http2Exception
public 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 Http2FrameSizePolicy
public void close()
Http2FrameWriter
close
in interface Http2FrameWriter
close
in interface Closeable
close
in interface AutoCloseable
public ChannelFuture writeData(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endStream, ChannelPromise promise)
Http2DataWriter
DATA
frame to the remote endpoint. This will result in one or more
frames being written to the context.writeData
in interface Http2DataWriter
ctx
- the context to use for writing.streamId
- the stream for which to send the frame.data
- the payload of the frame. This will be released by this method.padding
- 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
- indicates if this is the last frame to be sent for the stream.promise
- the promise for the write.public ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream, ChannelPromise promise)
Http2FrameWriter
writeHeaders
in interface Http2FrameWriter
ctx
- the context to use for writing.streamId
- the stream for which to send the frame.headers
- the headers to be sent.padding
- additional bytes that should be added to obscure the true content size. Must be between 0 and
256 (inclusive).endStream
- indicates if this is the last frame to be sent for the stream.promise
- the promise for the write.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.
public ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endStream, ChannelPromise promise)
Http2FrameWriter
writeHeaders
in interface Http2FrameWriter
ctx
- the context to use for writing.streamId
- the stream for which to send the frame.headers
- the headers to be sent.streamDependency
- the stream on which this stream should depend, or 0 if it should
depend on the connection.weight
- the weight for this stream.exclusive
- whether this stream should be the exclusive dependant of its parent.padding
- additional bytes that should be added to obscure the true content size. Must be between 0 and
256 (inclusive).endStream
- indicates if this is the last frame to be sent for the stream.promise
- the promise for the write.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.
public ChannelFuture writePriority(ChannelHandlerContext ctx, int streamId, int streamDependency, short weight, boolean exclusive, ChannelPromise promise)
Http2FrameWriter
writePriority
in interface Http2FrameWriter
ctx
- the context to use for writing.streamId
- the stream for which to send the frame.streamDependency
- the stream on which this stream should depend, or 0 if it should
depend on the connection.weight
- the weight for this stream.exclusive
- whether this stream should be the exclusive dependant of its parent.promise
- the promise for the write.public ChannelFuture writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode, ChannelPromise promise)
Http2FrameWriter
writeRstStream
in interface Http2FrameWriter
ctx
- the context to use for writing.streamId
- the stream for which to send the frame.errorCode
- the error code indicating the nature of the failure.promise
- the promise for the write.public ChannelFuture writeSettings(ChannelHandlerContext ctx, Http2Settings settings, ChannelPromise promise)
Http2FrameWriter
writeSettings
in interface Http2FrameWriter
ctx
- the context to use for writing.settings
- the settings to be sent.promise
- the promise for the write.public ChannelFuture writeSettingsAck(ChannelHandlerContext ctx, ChannelPromise promise)
Http2FrameWriter
writeSettingsAck
in interface Http2FrameWriter
ctx
- the context to use for writing.promise
- the promise for the write.public ChannelFuture writePing(ChannelHandlerContext ctx, boolean ack, long data, ChannelPromise promise)
Http2FrameWriter
writePing
in interface Http2FrameWriter
ctx
- the context to use for writing.ack
- indicates whether this is an ack of a PING frame previously received from the
remote endpoint.data
- the payload of the frame.promise
- the promise for the write.public ChannelFuture writePushPromise(ChannelHandlerContext ctx, int streamId, int promisedStreamId, Http2Headers headers, int padding, ChannelPromise promise)
Http2FrameWriter
writePushPromise
in interface Http2FrameWriter
ctx
- the context to use for writing.streamId
- the stream for which to send the frame.promisedStreamId
- the ID of the promised stream.headers
- the headers to be sent.padding
- additional bytes that should be added to obscure the true content size. Must be between 0 and
256 (inclusive).promise
- the promise for the write.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.
public ChannelFuture writeGoAway(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData, ChannelPromise promise)
Http2FrameWriter
writeGoAway
in interface Http2FrameWriter
ctx
- the context to use for writing.lastStreamId
- the last known stream of this endpoint.errorCode
- the error code, if the connection was abnormally terminated.debugData
- application-defined debug data. This will be released by this method.promise
- the promise for the write.public ChannelFuture writeWindowUpdate(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement, ChannelPromise promise)
Http2FrameWriter
writeWindowUpdate
in interface Http2FrameWriter
ctx
- the context to use for writing.streamId
- the stream for which to send the frame.windowSizeIncrement
- the number of bytes by which the local inbound flow control window
is increasing.promise
- the promise for the write.public ChannelFuture writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, ByteBuf payload, ChannelPromise promise)
Http2FrameWriter
writeFrame
in interface Http2FrameWriter
ctx
- the context to use for writing.frameType
- the frame type identifier.streamId
- the stream for which to send the frame.flags
- the flags to write for this frame.payload
- the payload to write for this frame. This will be released by this method.promise
- the promise for the write.Copyright © 2008–2024 The Netty Project. All rights reserved.