class WebSocket::Driver::Client
def initialize(socket, options = {})
def initialize(socket, options = {}) super @ready_state = -1 @key = Client.generate_key @accept = Hybi.generate_accept(@key) @http = HTTP::Response.new uri = URI.parse(@socket.url) unless VALID_SCHEMES.include?(uri.scheme) raise URIError, "#{ socket.url } is not a valid WebSocket URL" end path = (uri.path == '') ? '/' : uri.path @pathname = path + (uri.query ? '?' + uri.query : '') @headers['Host'] = Driver.host_header(uri) @headers['Upgrade'] = 'websocket' @headers['Connection'] = 'Upgrade' @headers['Sec-WebSocket-Key'] = @key @headers['Sec-WebSocket-Version'] = VERSION if @protocols.size > 0 @headers['Sec-WebSocket-Protocol'] = @protocols * ', ' end if uri.user auth = Base64.strict_encode64([uri.user, uri.password] * ':') @headers['Authorization'] = 'Basic ' + auth end end