- java.lang.Object
-
- io.netty5.handler.codec.http2.Http2ServerUpgradeCodec
-
- All Implemented Interfaces:
HttpServerUpgradeHandler.UpgradeCodec
@UnstableApi public class Http2ServerUpgradeCodec extends Object implements HttpServerUpgradeHandler.UpgradeCodec
Server-side codec for performing a cleartext upgrade from HTTP/1.x to HTTP/2.
-
-
Constructor Summary
Constructors Constructor Description Http2ServerUpgradeCodec(Http2ConnectionHandler connectionHandler)Creates the codec using a default name for the connection handler when adding to the pipeline.Http2ServerUpgradeCodec(Http2FrameCodec http2Codec, ChannelHandler... handlers)Creates the codec using a default name for the connection handler when adding to the pipeline.Http2ServerUpgradeCodec(String handlerName, Http2ConnectionHandler connectionHandler)Creates the codec providing an upgrade to the given handler for HTTP/2.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanprepareUpgradeResponse(ChannelHandlerContext ctx, FullHttpRequest upgradeRequest, HttpHeaders headers)Prepares theupgradeHeadersfor a protocol update based upon the contents ofupgradeRequest.Collection<CharSequence>requiredUpgradeHeaders()Gets all protocol-specific headers required by this protocol for a successful upgrade.voidupgradeTo(ChannelHandlerContext ctx, FullHttpRequest upgradeRequest)Performs an HTTP protocol upgrade from the source codec.
-
-
-
Constructor Detail
-
Http2ServerUpgradeCodec
public Http2ServerUpgradeCodec(Http2ConnectionHandler connectionHandler)
Creates the codec using a default name for the connection handler when adding to the pipeline.- Parameters:
connectionHandler- the HTTP/2 connection handler
-
Http2ServerUpgradeCodec
public Http2ServerUpgradeCodec(String handlerName, Http2ConnectionHandler connectionHandler)
Creates the codec providing an upgrade to the given handler for HTTP/2.- Parameters:
handlerName- the name of the HTTP/2 connection handler to be used in the pipeline, ornullto auto-generate the nameconnectionHandler- the HTTP/2 connection handler
-
Http2ServerUpgradeCodec
public Http2ServerUpgradeCodec(Http2FrameCodec http2Codec, ChannelHandler... handlers)
Creates the codec using a default name for the connection handler when adding to the pipeline.- Parameters:
http2Codec- the HTTP/2 frame handler.handlers- the handlers that will handle theHttp2Frames.
-
-
Method Detail
-
requiredUpgradeHeaders
public Collection<CharSequence> requiredUpgradeHeaders()
Description copied from interface:HttpServerUpgradeHandler.UpgradeCodecGets all protocol-specific headers required by this protocol for a successful upgrade. Any supplied header will be required to appear in theHttpHeaderNames.CONNECTIONheader as well.- Specified by:
requiredUpgradeHeadersin interfaceHttpServerUpgradeHandler.UpgradeCodec
-
prepareUpgradeResponse
public boolean prepareUpgradeResponse(ChannelHandlerContext ctx, FullHttpRequest upgradeRequest, HttpHeaders headers)
Description copied from interface:HttpServerUpgradeHandler.UpgradeCodecPrepares theupgradeHeadersfor a protocol update based upon the contents ofupgradeRequest. This method returns a boolean value to proceed or abort the upgrade in progress. Iffalseis returned, the upgrade is aborted and theupgradeRequestwill be passed through the inbound pipeline as if no upgrade was performed. Iftrueis returned, the upgrade will proceed to the next step which invokesHttpServerUpgradeHandler.UpgradeCodec.upgradeTo(io.netty5.channel.ChannelHandlerContext, io.netty5.handler.codec.http.FullHttpRequest). When returningtrue, you can add headers to theupgradeHeadersso that they are added to the 101 Switching protocols response.- Specified by:
prepareUpgradeResponsein interfaceHttpServerUpgradeHandler.UpgradeCodec
-
upgradeTo
public void upgradeTo(ChannelHandlerContext ctx, FullHttpRequest upgradeRequest)
Description copied from interface:HttpServerUpgradeHandler.UpgradeCodecPerforms an HTTP protocol upgrade from the source codec. This method is responsible for adding all handlers required for the new protocol.- Specified by:
upgradeToin interfaceHttpServerUpgradeHandler.UpgradeCodec- Parameters:
ctx- the context for the current handler.upgradeRequest- the request that triggered the upgrade to this protocol.
-
-