@UnstableApi public class Http2ServerUpgradeCodec extends java.lang.Object implements HttpServerUpgradeHandler.UpgradeCodec
Modifier and Type | Field and Description |
---|---|
private Http2ConnectionHandler |
connectionHandler |
private Http2FrameReader |
frameReader |
private java.lang.String |
handlerName |
private static InternalLogger |
logger |
private static java.util.List<java.lang.CharSequence> |
REQUIRED_UPGRADE_HEADERS |
private ChannelHandler |
upgradeToHandler |
Constructor and Description |
---|
Http2ServerUpgradeCodec(Http2Codec http2Codec)
Creates the codec using a default name for the connection handler when adding to the
pipeline.
|
Http2ServerUpgradeCodec(Http2ConnectionHandler connectionHandler)
Creates the codec using a default name for the connection handler when adding to the
pipeline.
|
Http2ServerUpgradeCodec(java.lang.String handlerName,
Http2Codec http2Codec)
Creates the codec providing an upgrade to the given handler for HTTP/2.
|
Http2ServerUpgradeCodec(java.lang.String handlerName,
Http2ConnectionHandler connectionHandler)
Creates the codec providing an upgrade to the given handler for HTTP/2.
|
Http2ServerUpgradeCodec(java.lang.String handlerName,
Http2ConnectionHandler connectionHandler,
ChannelHandler upgradeToHandler) |
Modifier and Type | Method and Description |
---|---|
private static ByteBuf |
createSettingsFrame(ChannelHandlerContext ctx,
ByteBuf payload)
Creates an HTTP2-Settings header with the given payload.
|
private Http2Settings |
decodeSettings(ChannelHandlerContext ctx,
ByteBuf frame)
Decodes the settings frame and returns the settings.
|
private Http2Settings |
decodeSettingsHeader(ChannelHandlerContext ctx,
java.lang.CharSequence settingsHeader)
Decodes the settings header and returns a
Http2Settings object. |
boolean |
prepareUpgradeResponse(ChannelHandlerContext ctx,
FullHttpRequest upgradeRequest,
HttpHeaders headers)
Prepares the
upgradeHeaders for a protocol update based upon the contents of upgradeRequest . |
java.util.Collection<java.lang.CharSequence> |
requiredUpgradeHeaders()
Gets all protocol-specific headers required by this protocol for a successful upgrade.
|
void |
upgradeTo(ChannelHandlerContext ctx,
FullHttpRequest upgradeRequest)
Performs an HTTP protocol upgrade from the source codec.
|
private static final InternalLogger logger
private static final java.util.List<java.lang.CharSequence> REQUIRED_UPGRADE_HEADERS
private final java.lang.String handlerName
private final Http2ConnectionHandler connectionHandler
private final ChannelHandler upgradeToHandler
private final Http2FrameReader frameReader
public Http2ServerUpgradeCodec(Http2ConnectionHandler connectionHandler)
connectionHandler
- the HTTP/2 connection handlerpublic Http2ServerUpgradeCodec(Http2Codec http2Codec)
http2Codec
- the HTTP/2 multiplexing handler.public Http2ServerUpgradeCodec(java.lang.String handlerName, Http2ConnectionHandler connectionHandler)
handlerName
- the name of the HTTP/2 connection handler to be used in the pipeline,
or null
to auto-generate the nameconnectionHandler
- the HTTP/2 connection handlerpublic Http2ServerUpgradeCodec(java.lang.String handlerName, Http2Codec http2Codec)
handlerName
- the name of the HTTP/2 connection handler to be used in the pipeline.http2Codec
- the HTTP/2 multiplexing handler.Http2ServerUpgradeCodec(java.lang.String handlerName, Http2ConnectionHandler connectionHandler, ChannelHandler upgradeToHandler)
public java.util.Collection<java.lang.CharSequence> requiredUpgradeHeaders()
HttpServerUpgradeHandler.UpgradeCodec
HttpHeaderNames.CONNECTION
header as well.requiredUpgradeHeaders
in interface HttpServerUpgradeHandler.UpgradeCodec
public boolean prepareUpgradeResponse(ChannelHandlerContext ctx, FullHttpRequest upgradeRequest, HttpHeaders headers)
HttpServerUpgradeHandler.UpgradeCodec
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 HttpServerUpgradeHandler.UpgradeCodec.upgradeTo(io.netty.channel.ChannelHandlerContext, io.netty.handler.codec.http.FullHttpRequest)
. When returning true
, you can add headers to
the upgradeHeaders
so that they are added to the 101 Switching protocols response.prepareUpgradeResponse
in interface HttpServerUpgradeHandler.UpgradeCodec
public void upgradeTo(ChannelHandlerContext ctx, FullHttpRequest upgradeRequest)
HttpServerUpgradeHandler.UpgradeCodec
upgradeTo
in interface HttpServerUpgradeHandler.UpgradeCodec
ctx
- the context for the current handler.upgradeRequest
- the request that triggered the upgrade to this protocol.private Http2Settings decodeSettingsHeader(ChannelHandlerContext ctx, java.lang.CharSequence settingsHeader) throws Http2Exception
Http2Settings
object.Http2Exception
private Http2Settings decodeSettings(ChannelHandlerContext ctx, ByteBuf frame) throws Http2Exception
Http2Exception
private static ByteBuf createSettingsFrame(ChannelHandlerContext ctx, ByteBuf payload)