Class: Async::WebSocket::UpgradeResponse
- Inherits:
-
Protocol::HTTP::Response
- Object
- Protocol::HTTP::Response
- Async::WebSocket::UpgradeResponse
- Includes:
- Protocol::WebSocket::Headers
- Defined in:
- lib/async/websocket/upgrade_response.rb
Overview
The response from the server back to the client for negotiating HTTP/1.x WebSockets.
Instance Method Summary collapse
-
#initialize(request, headers = nil, protocol: nil, &block) ⇒ UpgradeResponse
constructor
A new instance of UpgradeResponse.
Constructor Details
#initialize(request, headers = nil, protocol: nil, &block) ⇒ UpgradeResponse
Returns a new instance of UpgradeResponse.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/async/websocket/upgrade_response.rb', line 33 def initialize(request, headers = nil, protocol: nil, &block) headers = ::Protocol::HTTP::Headers[headers] if accept_nounce = request.headers[SEC_WEBSOCKET_KEY]&.first headers.add(SEC_WEBSOCKET_ACCEPT, Nounce.accept_digest(accept_nounce)) status = 101 else status = 400 end if protocol headers.add(SEC_WEBSOCKET_PROTOCOL, protocol) end body = Async::HTTP::Body::Hijack.wrap(request, &block) super(request.version, status, headers, body, PROTOCOL) end |