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.



15
16
17
18
19
20
21
22
23
# File 'lib/async/websocket/response.rb', line 15

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