NIOHTTPClientUpgradeHandler
A client-side channel handler that sends a HTTP upgrade handshake request to perform a HTTP-upgrade. When the first HTTP request is sent, this handler will add all appropriate headers to perform an upgrade to the a protocol. It may add headers for a set of protocols in preference order. If the upgrade fails (i.e. response is not 101 Switching Protocols), this handler simply removes itself from the pipeline. If the upgrade is successful, it upgrades the pipeline to the new protocol.
NIOHTTPClientUpgradeHandler.swift:93final class NIOHTTPClientUpgradeHandler
The request sends an order of preference to request which protocol it would like to use for the upgrade. It will only upgrade to the protocol that is returned first in the list and does not currently have the capability to upgrade to multiple simultaneous layered protocols.
Citizens in NIOHTTP1
Conformances
protocol ChannelHandler
Base protocol for handlers that handle I/O events or intercept an I/O operation.
protocol ChannelInboundHandler
ChannelHandler
which handles inbound I/O events for aChannel
.protocol ChannelOutboundHandler
ChannelHandler
which handles outbound I/O events or intercept an outbound I/O operation for aChannel
.protocol RemovableChannelHandler
A
RemovableChannelHandler
is aChannelHandler
that can be dynamically removed from aChannelPipeline
whilst theChannel
is operating normally. ARemovableChannelHandler
is required to remove itself from theChannelPipeline
(usingChannelHandlerContext.leavePipeline
) as soon as possible.protocol Sendable
A type whose values can safely be passed across concurrency domains by copying.
Show implementation details (3)
Hide implementation details
protocol _ChannelInboundHandler
Untyped
ChannelHandler
which handles inbound I/O events.protocol _ChannelOutboundHandler
Untyped
ChannelHandler
which handles outbound I/O events or intercept an outbound I/O operation.protocol _EmittingChannelHandler
ChannelHandler which will emit data by calling
ChannelHandlerContext.write
.
Typealiases
Type members
init(upgraders: [NIOHTTPClientProtocolUpgrader], httpHandlers: [RemovableChannelHandler], upgradeCompletionHandler: @escaping (ChannelHandlerContext) -> Void
) Create a
HTTPClientUpgradeHandler
.
Instance members
func channelRead(context: ChannelHandlerContext, data: NIOAny
) func write(context: ChannelHandlerContext, data: NIOAny, promise: EventLoopPromise<Void>?
)
Instance features
func bind(context: ChannelHandlerContext, to: SocketAddress, promise: EventLoopPromise<Void>?
) func channelActive(context: ChannelHandlerContext
) func channelInactive(context: ChannelHandlerContext
) func channelReadComplete(context: ChannelHandlerContext
) func channelRegistered(context: ChannelHandlerContext
) func channelUnregistered(context: ChannelHandlerContext
) func channelWritabilityChanged(context: ChannelHandlerContext
) func close(context: ChannelHandlerContext, mode: CloseMode, promise: EventLoopPromise<Void>?
) func connect(context: ChannelHandlerContext, to: SocketAddress, promise: EventLoopPromise<Void>?
) func errorCaught(context: ChannelHandlerContext, error: Error
) func flush(context: ChannelHandlerContext
) func handlerAdded(context: ChannelHandlerContext
) Do nothing by default.
func handlerRemoved(context: ChannelHandlerContext
) Do nothing by default.
func read(context: ChannelHandlerContext
) func register(context: ChannelHandlerContext, promise: EventLoopPromise<Void>?
) func removeHandler(context: ChannelHandlerContext, removalToken: ChannelHandlerContext.RemovalToken
) Implements the default behaviour which is to synchronously remove the handler from the pipeline. Thanks to this, stateless
ChannelHandler
s can just useRemovableChannelHandler
as a marker-protocol and declare themselves as removable without writing any extra code.func triggerUserOutboundEvent(context: ChannelHandlerContext, event: Any, promise: EventLoopPromise<Void>?
) func unwrapInboundIn(NIOAny
) -> InboundIn func unwrapOutboundIn(NIOAny
) -> OutboundIn func userInboundEventTriggered(context: ChannelHandlerContext, event: Any
) func wrapInboundOut(InboundOut
) -> NIOAny func wrapOutboundOut(OutboundOut
) -> NIOAny