Class: Async::WebSocket::ConnectResponse

Inherits:
Protocol::HTTP::Response
  • Object
show all
Includes:
Protocol::WebSocket::Headers
Defined in:
lib/async/websocket/connect_response.rb

Overview

The response from the server back to the client for negotiating HTTP/2 WebSockets.

Instance Method Summary collapse

Constructor Details

#initialize(request, headers = nil, protocol: nil, &block) ⇒ ConnectResponse

Returns a new instance of ConnectResponse.


32
33
34
35
36
37
38
39
40
41
# File 'lib/async/websocket/connect_response.rb', line 32

def initialize(request, headers = nil, protocol: nil, &block)
	headers = ::Protocol::HTTP::Headers[headers]
	
	if protocol
		headers.add(SEC_WEBSOCKET_PROTOCOL, protocol)
	end
	
	body = Async::HTTP::Body::Hijack.wrap(request, &block)
	super(request.version, 200, headers, body)
end