HTTPServerUpgradeHandler
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.
-
Declaration
Swift
public typealias InboundIn = HTTPServerRequestPart
-
Declaration
Swift
public typealias InboundOut = HTTPServerRequestPart
-
Declaration
Swift
public typealias OutboundOut = HTTPServerResponsePart
-
Create a
HTTPServerUpgradeHandler
.Declaration
Swift
public init(upgraders: [HTTPServerProtocolUpgrader], httpEncoder: HTTPResponseEncoder, extraHTTPHandlers: [RemovableChannelHandler], upgradeCompletionHandler: @escaping (ChannelHandlerContext) -> Void)
Parameters
upgraders
All
HTTPServerProtocolUpgrader
objects that this pipeline will be able to use to handle HTTP upgrade.httpEncoder
The
HTTPResponseEncoder
encoding 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.extraHTTPHandlers
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.upgradeCompletionHandler
A block that will be fired when HTTP upgrade is complete.
-
Declaration
Swift
public func channelRead(context: ChannelHandlerContext, data: NIOAny)
-
Declaration
Swift
public func removeHandler(context: ChannelHandlerContext, removalToken: ChannelHandlerContext.RemovalToken)