HTTPProtocolUpgrader

public protocol HTTPProtocolUpgrader

An object that implements ProtocolUpgrader knows how to handle HTTP upgrade to a protocol.

  • The protocol this upgrader knows how to support.

    Declaration

    Swift

    var supportedProtocol: 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.

    Declaration

    Swift

    var requiredUpgradeHeaders: [String] { get }
  • 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 throw.

    Declaration

    Swift

    func buildUpgradeResponse(upgradeRequest: HTTPRequestHead, initialResponseHeaders: HTTPHeaders) throws -> HTTPHeaders
  • 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.

    Declaration

    Swift

    func upgrade(ctx: ChannelHandlerContext, upgradeRequest: HTTPRequestHead) -> EventLoopFuture<Void>