Module: Async::WebSocket::Response

Defined in:
lib/async/websocket/response.rb

Class Method Summary collapse

Class Method Details

.for(request, headers = nil, **options, &body) ⇒ Object

Send the request to the given connection.

Raises:



30
31
32
33
34
35
36
37
38
# File 'lib/async/websocket/response.rb', line 30

def self.for(request, headers = nil, **options, &body)
	if request.version =~ /http\/1/i
		return UpgradeResponse.new(request, headers, **options, &body)
	elsif request.version =~ /h2/i
		return ConnectResponse.new(request, headers, **options, &body)
	end
	
	raise ProtocolError, "Unsupported HTTP version: #{request.version}!"
end