NIOHTTPClientProtocolUpgrader

public protocol NIOHTTPClientProtocolUpgrader

An object that implements NIOHTTPClientProtocolUpgrader knows how to handle HTTP upgrade to a protocol on a client-side channel. It has the option of denying this upgrade based upon the server response.

  • The protocol this upgrader knows how to support.

    Declaration

    Swift

    var supportedProtocol: String { get }
  • All the header fields the protocol requires in the request to successfully upgrade. These header fields will be added to the outbound request’s “Connection” header field. It is the responsibility of the custom headers call to actually add these required headers.

    Declaration

    Swift

    var requiredUpgradeHeaders: [String] { get }
  • Additional headers to be added to the request, beyond the “Upgrade” and “Connection” headers.

    Declaration

    Swift

    func addCustom(upgradeRequestHeaders: inout HTTPHeaders)
  • Gives the receiving upgrader the chance to deny the upgrade based on the upgrade HTTP response.

    Declaration

    Swift

    func shouldAllowUpgrade(upgradeResponse: HTTPResponseHead) -> Bool
  • 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(context: ChannelHandlerContext, upgradeResponse: HTTPResponseHead) -> EventLoopFuture<Void>