HTTPServerProtocolUpgrader
An object that implements HTTPServerProtocolUpgrader
knows how to handle HTTP upgrade to a protocol on a server-side channel.
protocol HTTPServerProtocolUpgrader
Browse conforming typesAn object that implements HTTPServerProtocolUpgrader
knows how to handle HTTP upgrade to a protocol on a server-side channel.
protocol HTTPServerProtocolUpgrader
import NIOHTTP1
var requiredUpgradeHeaders: [String] { get }
All the header fields the protocol needs in the request to successfully upgrade. These header fields will be provided to the handler when it is asked to handle the upgrade. They will also be validated against the inbound request’s Connection header field.
var supportedProtocol: String { get }
The protocol this upgrader knows how to support.
func buildUpgradeResponse(channel: Channel, upgradeRequest: HTTPRequestHead, initialResponseHeaders: HTTPHeaders) -> EventLoopFuture<HTTPHeaders>
Builds the upgrade response headers. Should return any headers that need to be supplied to the client in the 101 Switching Protocols response. If upgrade cannot proceed for any reason, this function should fail the future.
func upgrade(context: ChannelHandlerContext, upgradeRequest: HTTPRequestHead) -> EventLoopFuture<Void>
Called when the upgrade response has been flushed. At this time it is safe to mutate the channel pipeline to add whatever channel handlers are required. Until the returned EventLoopFuture
succeeds, all received data will be buffered.