Initializerswift-nio 2.72.0NIOWebSocket
init(requestKey:maxFrameSize:automaticErrorHandling:upgradePipelineHandler:)
NIOWebSocketClientUpgrader.swift:43init(requestKey: String = randomRequestKey(), maxFrameSize: Int = 1 << 14, automaticErrorHandling: Bool = true, upgradePipelineHandler: @escaping (Channel, HTTPResponseHead) -> EventLoopFuture<Void>)
Parameters
- requestKey
sent to the server in the
Sec-WebSocket-Key
HTTP header. Default is random request key.- maxFrameSize
largest incoming
WebSocketFrame
size in bytes. Default is 16,384 bytes.- automaticErrorHandling
If true, adds
WebSocketProtocolErrorHandler
to the channel pipeline to catch and respond to WebSocket protocol errors. Default is true.- upgradePipelineHandler
called once the upgrade was successful
Other members in extension
Type members
static func randomRequestKey(
) -> String Generates a random WebSocket Request Key by generating 16 bytes randomly using the
SystemRandomNumberGenerator
and encoding them as a base64 string as defined in RFC6455 https://tools.ietf.org/html/rfc6455#section-4.1.static func randomRequestKey<Generator>(using: inout Generator
) -> String Generates a random WebSocket Request Key by generating 16 bytes randomly and encoding them as a base64 string as defined in RFC6455 https://tools.ietf.org/html/rfc6455#section-4.1
Instance members
let requiredUpgradeHeaders: [String]
None of the websocket headers are actually defined as ‘required’.
let supportedProtocol: String
RFC 6455 specs this as the required entry in the Upgrade header.
func addCustom(upgradeRequestHeaders: inout HTTPHeaders
) Add additional headers that are needed for a WebSocket upgrade request.
func shouldAllowUpgrade(upgradeResponse: HTTPResponseHead
) -> Bool func upgrade(context: ChannelHandlerContext, upgradeResponse: HTTPResponseHead
) -> EventLoopFuture<Void>