class WebSocket::Driver::Hybi
def handshake_response
def handshake_response sec_key = @socket.env['HTTP_SEC_WEBSOCKET_KEY'] version = @socket.env['HTTP_SEC_WEBSOCKET_VERSION'] unless version == VERSION raise ProtocolError.new("Unsupported WebSocket version: #{ VERSION }") end unless sec_key raise ProtocolError.new('Missing handshake request header: Sec-WebSocket-Key') end @headers['Upgrade'] = 'websocket' @headers['Connection'] = 'Upgrade' @headers['Sec-WebSocket-Accept'] = Hybi.generate_accept(sec_key) @headers['Sec-WebSocket-Protocol'] = @protocol if @protocol extensions = @extensions.generate_response(@socket.env['HTTP_SEC_WEBSOCKET_EXTENSIONS']) @headers['Sec-WebSocket-Extensions'] = extensions if extensions start = 'HTTP/1.1 101 Switching Protocols' headers = [start, @headers.to_s, ''] headers.join("\r\n") end