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 16 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 39 def headers @parser.headers end
The same as headers, except that the hash keys are downcased
# File lib/em-websocket/handshake.rb, line 45 def headers_downcased @headers end
Returns the WebSocket origin header if provided
# File lib/em-websocket/handshake.rb, line 66 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 51 def path @path end
# File lib/em-websocket/handshake.rb, line 60 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 56 def query_string @query_string end
Generated with the Darkfish Rdoc Generator 2.