Module io.netty.codec.http2
Package io.netty5.handler.codec.http2
Class DefaultHttp2ConnectionEncoder
- java.lang.Object
-
- io.netty5.handler.codec.http2.DefaultHttp2ConnectionEncoder
-
- All Implemented Interfaces:
Http2ConnectionEncoder,Http2DataWriter,Http2FrameWriter,Http2SettingsReceivedConsumer,Closeable,AutoCloseable
@UnstableApi public class DefaultHttp2ConnectionEncoder extends Object implements Http2ConnectionEncoder, Http2SettingsReceivedConsumer
Default implementation ofHttp2ConnectionEncoder.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classDefaultHttp2ConnectionEncoder.FlowControlledBaseCommon base type for payloads to deliver via flow-control.-
Nested classes/interfaces inherited from interface io.netty5.handler.codec.http2.Http2FrameWriter
Http2FrameWriter.Configuration
-
-
Constructor Summary
Constructors Constructor Description DefaultHttp2ConnectionEncoder(Http2Connection connection, Http2FrameWriter frameWriter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this writer and frees any allocated resources.Http2FrameWriter.Configurationconfiguration()Get the configuration related elements for thisHttp2FrameWriterHttp2Connectionconnection()Provides direct access to the underlying connection.voidconsumeReceivedSettings(Http2Settings settings)Consume the most recently received but not yet ACKed settings.Http2RemoteFlowControllerflowController()Provides the remote flow controller for managing outbound traffic.Http2FrameWriterframeWriter()Provides direct access to the underlying frame writer object.voidlifecycleManager(Http2LifecycleManager lifecycleManager)Sets the lifecycle manager.Http2SettingspollSentSettings()Gets the local settings on the top of the queue that has been sent but not ACKed.voidremoteSettings(Http2Settings settings)Sets the settings for the remote endpoint of the HTTP/2 connection.Future<Void>writeData(ChannelHandlerContext ctx, int streamId, Buffer data, int padding, boolean endOfStream)Writes aDATAframe to the remote endpoint.Future<Void>writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, Buffer payload)Writes the given data to the internalHttp2FrameWriterwithout performing any state checks on the connection/stream.Future<Void>writeGoAway(ChannelHandlerContext ctx, int lastStreamId, long errorCode, Buffer debugData)Writes a GO_AWAY frame to the remote endpoint.Future<Void>writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream)Writes a HEADERS frame to the remote endpoint.Future<Void>writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endOfStream)Writes a HEADERS frame with priority specified to the remote endpoint.Future<Void>writePing(ChannelHandlerContext ctx, boolean ack, long data)Writes a PING frame to the remote endpoint.Future<Void>writePriority(ChannelHandlerContext ctx, int streamId, int streamDependency, short weight, boolean exclusive)Writes a PRIORITY frame to the remote endpoint.Future<Void>writePushPromise(ChannelHandlerContext ctx, int streamId, int promisedStreamId, Http2Headers headers, int padding)Writes a PUSH_PROMISE frame to the remote endpoint.Future<Void>writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode)Writes a RST_STREAM frame to the remote endpoint.Future<Void>writeSettings(ChannelHandlerContext ctx, Http2Settings settings)Writes a SETTINGS frame to the remote endpoint.Future<Void>writeSettingsAck(ChannelHandlerContext ctx)Writes a SETTINGS acknowledgment to the remote endpoint.Future<Void>writeWindowUpdate(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement)Writes a WINDOW_UPDATE frame to the remote endpoint.
-
-
-
Constructor Detail
-
DefaultHttp2ConnectionEncoder
public DefaultHttp2ConnectionEncoder(Http2Connection connection, Http2FrameWriter frameWriter)
-
-
Method Detail
-
lifecycleManager
public void lifecycleManager(Http2LifecycleManager lifecycleManager)
Description copied from interface:Http2ConnectionEncoderSets the lifecycle manager. Must be called as part of initialization before the encoder is used.- Specified by:
lifecycleManagerin interfaceHttp2ConnectionEncoder
-
frameWriter
public Http2FrameWriter frameWriter()
Description copied from interface:Http2ConnectionEncoderProvides direct access to the underlying frame writer object.- Specified by:
frameWriterin interfaceHttp2ConnectionEncoder
-
connection
public Http2Connection connection()
Description copied from interface:Http2ConnectionEncoderProvides direct access to the underlying connection.- Specified by:
connectionin interfaceHttp2ConnectionEncoder
-
flowController
public final Http2RemoteFlowController flowController()
Description copied from interface:Http2ConnectionEncoderProvides the remote flow controller for managing outbound traffic.- Specified by:
flowControllerin interfaceHttp2ConnectionEncoder
-
remoteSettings
public void remoteSettings(Http2Settings settings) throws Http2Exception
Description copied from interface:Http2ConnectionEncoderSets the settings for the remote endpoint of the HTTP/2 connection.- Specified by:
remoteSettingsin interfaceHttp2ConnectionEncoder- Throws:
Http2Exception
-
writeData
public Future<Void> writeData(ChannelHandlerContext ctx, int streamId, Buffer data, int padding, boolean endOfStream)
Description copied from interface:Http2DataWriterWrites aDATAframe to the remote endpoint. This will result in one or more frames being written to the context.- Specified by:
writeDatain interfaceHttp2DataWriter- Parameters:
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.endOfStream- indicates if this is the last frame to be sent for the stream.- Returns:
- the future for the write.
-
writeHeaders
public Future<Void> writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream)
Description copied from interface:Http2FrameWriterWrites a HEADERS frame to the remote endpoint.- Specified by:
writeHeadersin interfaceHttp2FrameWriter- Parameters:
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.- Returns:
- 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.
-
writeHeaders
public Future<Void> writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endOfStream)
Description copied from interface:Http2FrameWriterWrites a HEADERS frame with priority specified to the remote endpoint.- Specified by:
writeHeadersin interfaceHttp2FrameWriter- Parameters:
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).endOfStream- indicates if this is the last frame to be sent for the stream.- Returns:
- 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.
-
writePriority
public Future<Void> writePriority(ChannelHandlerContext ctx, int streamId, int streamDependency, short weight, boolean exclusive)
Description copied from interface:Http2FrameWriterWrites a PRIORITY frame to the remote endpoint.- Specified by:
writePriorityin interfaceHttp2FrameWriter- Parameters:
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.- Returns:
- the future for the write.
-
writeRstStream
public Future<Void> writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode)
Description copied from interface:Http2FrameWriterWrites a RST_STREAM frame to the remote endpoint.- Specified by:
writeRstStreamin interfaceHttp2FrameWriter- Parameters:
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.- Returns:
- the future for the write.
-
writeSettings
public Future<Void> writeSettings(ChannelHandlerContext ctx, Http2Settings settings)
Description copied from interface:Http2FrameWriterWrites a SETTINGS frame to the remote endpoint.- Specified by:
writeSettingsin interfaceHttp2FrameWriter- Parameters:
ctx- the context to use for writing.settings- the settings to be sent.- Returns:
- the future for the write.
-
writeSettingsAck
public Future<Void> writeSettingsAck(ChannelHandlerContext ctx)
Description copied from interface:Http2FrameWriterWrites a SETTINGS acknowledgment to the remote endpoint.- Specified by:
writeSettingsAckin interfaceHttp2FrameWriter- Parameters:
ctx- the context to use for writing.- Returns:
- the future for the write.
-
writePing
public Future<Void> writePing(ChannelHandlerContext ctx, boolean ack, long data)
Description copied from interface:Http2FrameWriterWrites a PING frame to the remote endpoint.- Specified by:
writePingin interfaceHttp2FrameWriter- Parameters:
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.- Returns:
- the future for the write.
-
writePushPromise
public Future<Void> writePushPromise(ChannelHandlerContext ctx, int streamId, int promisedStreamId, Http2Headers headers, int padding)
Description copied from interface:Http2FrameWriterWrites a PUSH_PROMISE frame to the remote endpoint.- Specified by:
writePushPromisein interfaceHttp2FrameWriter- Parameters:
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).- Returns:
- 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.
-
writeGoAway
public Future<Void> writeGoAway(ChannelHandlerContext ctx, int lastStreamId, long errorCode, Buffer debugData)
Description copied from interface:Http2FrameWriterWrites a GO_AWAY frame to the remote endpoint.- Specified by:
writeGoAwayin interfaceHttp2FrameWriter- Parameters:
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.- Returns:
- the future for the write.
-
writeWindowUpdate
public Future<Void> writeWindowUpdate(ChannelHandlerContext ctx, int streamId, int windowSizeIncrement)
Description copied from interface:Http2FrameWriterWrites a WINDOW_UPDATE frame to the remote endpoint.- Specified by:
writeWindowUpdatein interfaceHttp2FrameWriter- Parameters:
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.- Returns:
- the future for the write.
-
writeFrame
public Future<Void> writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, Buffer payload)
Description copied from interface:Http2ConnectionEncoderWrites the given data to the internalHttp2FrameWriterwithout performing any state checks on the connection/stream.- Specified by:
writeFramein interfaceHttp2ConnectionEncoder- Specified by:
writeFramein interfaceHttp2FrameWriter- Parameters:
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.- Returns:
- the future for the write.
-
close
public void close()
Description copied from interface:Http2FrameWriterCloses this writer and frees any allocated resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceHttp2FrameWriter
-
pollSentSettings
public Http2Settings pollSentSettings()
Description copied from interface:Http2ConnectionEncoderGets the local settings on the top of the queue that has been sent but not ACKed. This may returnnull.- Specified by:
pollSentSettingsin interfaceHttp2ConnectionEncoder
-
configuration
public Http2FrameWriter.Configuration configuration()
Description copied from interface:Http2FrameWriterGet the configuration related elements for thisHttp2FrameWriter- Specified by:
configurationin interfaceHttp2FrameWriter
-
consumeReceivedSettings
public void consumeReceivedSettings(Http2Settings settings)
Description copied from interface:Http2SettingsReceivedConsumerConsume the most recently received but not yet ACKed settings.- Specified by:
consumeReceivedSettingsin interfaceHttp2SettingsReceivedConsumer
-
-