public final class HTTPServerUpgradeHandler : ChannelInboundHandler, RemovableChannelHandler
A server-side channel handler that receives HTTP requests and optionally performs a HTTP-upgrade. Removes itself from the channel pipeline after the first inbound request on the connection, regardless of whether the upgrade succeeded or not.
This handler behaves a bit differently from its Netty counterpart because it does not allow upgrade on any request but the first on a connection. This is primarily to handle clients that pipeline: it’s sufficiently difficult to ensure that the upgrade happens at a safe time while dealing with pipelined requests that we choose to punt on it entirely and not allow it. As it happens this is mostly fine: the odds of someone needing to upgrade midway through the lifetime of a connection are very low.
HTTPServerProtocolUpgraderobjects that this pipeline will be able to use to handle HTTP upgrade.
HTTPResponseEncoderencoding responses from this handler and which will be removed from the pipeline once the upgrade response is sent. This is used to ensure that the pipeline will be in a clean state after upgrade.
Any other handlers that are directly related to handling HTTP. At the very least this should include the
HTTPDecoder, but should also include any other handler that cannot tolerate receiving non-HTTP data.
A block that will be fired when HTTP upgrade is complete.
public func channelRead(context: ChannelHandlerContext, data: NIOAny)
public func removeHandler(context: ChannelHandlerContext, removalToken: ChannelHandlerContext.RemovalToken)