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
Classes: Wrapper
Instance Method Summary collapse
- #call(connection) ⇒ Object
-
#initialize(request, protocols: [], version: 13) ⇒ ConnectRequest
constructor
A new instance of ConnectRequest.
Constructor Details
#initialize(request, protocols: [], version: 13) ⇒ ConnectRequest
Returns a new instance of ConnectRequest.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/async/websocket/connect_request.rb', line 68 def initialize(request, protocols: [], version: 13) body = Async::HTTP::Body::Writable.new headers = [] headers << [SEC_WEBSOCKET_VERSION, version] if protocols.any? headers << [SEC_WEBSOCKET_PROTOCOL, protocols.join(',')] end merged_headers = ::Protocol::HTTP::Headers::Merged.new(request.headers, headers) super(request.scheme, request., ::Protocol::HTTP::Methods::CONNECT, request.path, nil, merged_headers, body, PROTOCOL) end |