module Async::WebSocket::Response

Public Class Methods

for(request, headers = nil, **options, &body) click to toggle source

Send the request to the given connection.

# 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