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

public Class Http2ServerUpgradeCodec

extends Object
implements UpgradeCodec
Class Inheritance
All Implemented Interfaces
io.netty5.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec
Annotations
@UnstableApi
Imports
io.netty5.buffer.Buffer, io.netty5.channel.ChannelHandler, .ChannelHandlerContext, io.netty5.handler.codec.base64.Base64, io.netty5.handler.codec.http.FullHttpRequest, .HttpServerUpgradeHandler, io.netty5.handler.codec.http.headers.HttpHeaders, io.netty5.util.internal.UnstableApi, io.netty5.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.nio.charset.StandardCharsets, java.util.Collection, .Collections, .Iterator, .List

Server-side codec for performing a cleartext upgrade from HTTP/1.x to HTTP/2.

Field Summary

Modifier and TypeField and Description
private final Http2ConnectionHandler
private static final ChannelHandler[]
private final Http2FrameReader
private final String
private final ChannelHandler[]
private static final InternalLogger
private static final List<CharSequence>
private Http2Settings

Constructor Summary

AccessConstructor and Description
public
Http2ServerUpgradeCodec(Http2ConnectionHandler
the HTTP/2 connection handler
connectionHandler
)

Creates the codec using a default name for the connection handler when adding to the pipeline.

public
Http2ServerUpgradeCodec(String
the name of the HTTP/2 connection handler to be used in the pipeline, or null to auto-generate the name
handlerName
,
Http2ConnectionHandler
the HTTP/2 connection handler
connectionHandler
)

Creates the codec providing an upgrade to the given handler for HTTP/2.

public
Http2ServerUpgradeCodec(Http2FrameCodec
the HTTP/2 frame handler.
http2Codec
,
ChannelHandler...
the handlers that will handle the Http2Frames.
handlers
)

Creates the codec using a default name for the connection handler when adding to the pipeline.

private
Http2ServerUpgradeCodec(String handlerName, Http2ConnectionHandler connectionHandler, ChannelHandler... handlers)

Method Summary

Modifier and TypeMethod and Description
private static Buffer
createSettingsFrame(ChannelHandlerContext ctx, Buffer payload)

Creates an HTTP2-Settings header with the given payload.

private Http2Settings
decodeSettings(ChannelHandlerContext ctx, Buffer frame)

Decodes the settings frame and returns the settings.

private Http2Settings
decodeSettingsHeader(ChannelHandlerContext ctx, CharSequence settingsHeader)

Decodes the settings header and returns a Http2Settings object.

public boolean
prepareUpgradeResponse(ChannelHandlerContext ctx, FullHttpRequest upgradeRequest, HttpHeaders headers)

Implements io.netty5.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec.prepareUpgradeResponse.

Prepares the upgradeHeaders for a protocol update based upon the contents of upgradeRequest.
public Collection<CharSequence>
requiredUpgradeHeaders()

Implements io.netty5.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec.requiredUpgradeHeaders.

Gets all protocol-specific headers required by this protocol for a successful upgrade.
public void
upgradeTo(final ChannelHandlerContext
the context for the current handler.
ctx
,
FullHttpRequest
the request that triggered the upgrade to this protocol.
upgradeRequest
)

Implements io.netty5.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec.upgradeTo.

Performs an HTTP protocol upgrade from the source codec.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionHandlerback to summary
private final Http2ConnectionHandler connectionHandler
EMPTY_HANDLERSback to summary
private static final ChannelHandler[] EMPTY_HANDLERS
frameReaderback to summary
private final Http2FrameReader frameReader
handlerNameback to summary
private final String handlerName
handlersback to summary
private final ChannelHandler[] handlers
loggerback to summary
private static final InternalLogger logger
REQUIRED_UPGRADE_HEADERSback to summary
private static final List<CharSequence> REQUIRED_UPGRADE_HEADERS
settingsback to summary
private Http2Settings settings

Constructor Detail

Http2ServerUpgradeCodecback to summary
public Http2ServerUpgradeCodec(Http2ConnectionHandler connectionHandler)

Creates the codec using a default name for the connection handler when adding to the pipeline.

Parameters
connectionHandler:Http2ConnectionHandler

the HTTP/2 connection handler

Http2ServerUpgradeCodecback to summary
public Http2ServerUpgradeCodec(String handlerName, Http2ConnectionHandler connectionHandler)

Creates the codec providing an upgrade to the given handler for HTTP/2.

Parameters
handlerName:String

the name of the HTTP/2 connection handler to be used in the pipeline, or null to auto-generate the name

connectionHandler:Http2ConnectionHandler

the HTTP/2 connection handler

Http2ServerUpgradeCodecback to summary
public Http2ServerUpgradeCodec(Http2FrameCodec http2Codec, ChannelHandler... handlers)

Creates the codec using a default name for the connection handler when adding to the pipeline.

Parameters
http2Codec:Http2FrameCodec

the HTTP/2 frame handler.

handlers:ChannelHandler[]

the handlers that will handle the Http2Frames.

Http2ServerUpgradeCodecback to summary
private Http2ServerUpgradeCodec(String handlerName, Http2ConnectionHandler connectionHandler, ChannelHandler... handlers)

Method Detail

createSettingsFrameback to summary
private static Buffer createSettingsFrame(ChannelHandlerContext ctx, Buffer payload)

Creates an HTTP2-Settings header with the given payload. The payload buffer is released.

decodeSettingsback to summary
private Http2Settings decodeSettings(ChannelHandlerContext ctx, Buffer frame) throws Http2Exception

Decodes the settings frame and returns the settings.

decodeSettingsHeaderback to summary
private Http2Settings decodeSettingsHeader(ChannelHandlerContext ctx, CharSequence settingsHeader) throws Http2Exception

Decodes the settings header and returns a Http2Settings object.

prepareUpgradeResponseback to summary
public boolean prepareUpgradeResponse(ChannelHandlerContext ctx, FullHttpRequest upgradeRequest, HttpHeaders headers)

Implements io.netty5.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec.prepareUpgradeResponse.

Doc from io.netty5.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec.prepareUpgradeResponse.

Prepares the upgradeHeaders for a protocol update based upon the contents of upgradeRequest. This method returns a boolean value to proceed or abort the upgrade in progress. If false is returned, the upgrade is aborted and the upgradeRequest will be passed through the inbound pipeline as if no upgrade was performed. If true is returned, the upgrade will proceed to the next step which invokes upgradeTo. When returning true, you can add headers to the upgradeHeaders so that they are added to the 101 Switching protocols response.

Annotations
@Override
requiredUpgradeHeadersback to summary
public Collection<CharSequence> requiredUpgradeHeaders()

Implements io.netty5.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec.requiredUpgradeHeaders.

Doc from io.netty5.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec.requiredUpgradeHeaders.

Gets all protocol-specific headers required by this protocol for a successful upgrade. Any supplied header will be required to appear in the HttpHeaderNames#CONNECTION header as well.

Annotations
@Override
upgradeToback to summary
public void upgradeTo(final ChannelHandlerContext ctx, FullHttpRequest upgradeRequest)

Implements io.netty5.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec.upgradeTo.

Doc from io.netty5.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec.upgradeTo.

Performs an HTTP protocol upgrade from the source codec. This method is responsible for adding all handlers required for the new protocol.

Parameters
ctx:ChannelHandlerContext

the context for the current handler.

upgradeRequest:FullHttpRequest

the request that triggered the upgrade to this protocol.

Annotations
@Override