Class: Async::WebSocket::ConnectRequest
- Inherits:
-
Protocol::HTTP::Request
- Object
- Protocol::HTTP::Request
- Async::WebSocket::ConnectRequest
- Includes:
- Protocol::WebSocket::Headers
- Defined in:
- lib/async/websocket/connect_request.rb
Overview
This is required for HTTP/1.x to upgrade the connection to the WebSocket protocol. See tools.ietf.org/html/rfc8441 for more details.
Defined Under Namespace
Instance Method Summary collapse
- #call(connection) ⇒ Object
-
#initialize(request, protocols: [], version: 13, &block) ⇒ ConnectRequest
constructor
A new instance of ConnectRequest.
Constructor Details
#initialize(request, protocols: [], version: 13, &block) ⇒ ConnectRequest
Returns a new instance of ConnectRequest.
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/async/websocket/connect_request.rb', line 82 def initialize(request, protocols: [], version: 13, &block) body = Hijack.new(self) headers = ::Protocol::HTTP::Headers[request.headers] headers.add(SEC_WEBSOCKET_VERSION, String(version)) if protocols.any? headers.add(SEC_WEBSOCKET_PROTOCOL, protocols.join(',')) end super(request.scheme, request., ::Protocol::HTTP::Methods::CONNECT, request.path, nil, headers, body, PROTOCOL) end |