Object
Resposible for creating the server handshake response
Unfortunately drafts 75 & 76 require knowledge of whether the connection is being terminated as ws/wss in order to generate the correct handshake response
# File lib/em-websocket/handshake.rb, line 15 def initialize(secure) @parser = Http::Parser.new @secure = secure @parser.on_headers_complete = proc { |headers| @headers = Hash[headers.map { |k,v| [k.downcase, v] }] } end
Returns the WebSocket upgrade headers as a hash.
Keys are strings, unmodified from the request.
# File lib/em-websocket/handshake.rb, line 38 def headers @parser.headers end
The same as headers, except that the hash keys are downcased
# File lib/em-websocket/handshake.rb, line 44 def headers_downcased @headers end
Returns the WebSocket origin header if provided
# File lib/em-websocket/handshake.rb, line 65 def origin @headers["origin"] || @headers["sec-websocket-origin"] || nil end
Returns the request path (excluding any query params)
# File lib/em-websocket/handshake.rb, line 50 def path @parser.request_path end
# File lib/em-websocket/handshake.rb, line 59 def query Hash[query_string.split('&').map { |c| c.split('=', 2) }] end
Returns the query params as a string foo=bar&baz=...
# File lib/em-websocket/handshake.rb, line 55 def query_string @parser.query_string end
Generated with the Darkfish Rdoc Generator 2.