Class: EventMachine::WebSocket::Handler76
- Defined in:
- lib/em-websocket/handler76.rb
Constant Summary collapse
- TERMINATE_STRING =
“377000” is octet version and “xffx00” is hex version
"\xff\x00"
Instance Attribute Summary
Attributes inherited from Handler
Instance Method Summary collapse
Methods inherited from Handler
Constructor Details
This class inherits a constructor from EventMachine::WebSocket::Handler
Instance Method Details
#handshake ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/em-websocket/handler76.rb', line 9 def handshake challenge_response = solve_challenge( @request['Sec-WebSocket-Key1'], @request['Sec-WebSocket-Key2'], @request['Third-Key'] ) location = "#{@request['Host'].scheme}://#{@request['Host'].host}" location << ":#{@request['Host'].port}" if @request['Host'].port location << @request['Path'] upgrade = "HTTP/1.1 101 WebSocket Protocol Handshake\r\n" upgrade << "Upgrade: WebSocket\r\n" upgrade << "Connection: Upgrade\r\n" upgrade << "Sec-WebSocket-Location: #{location}\r\n" upgrade << "Sec-WebSocket-Origin: #{@request['Origin']}\r\n" if protocol = @request['Sec-WebSocket-Protocol'] validate_protocol!(protocol) upgrade << "Sec-WebSocket-Protocol: #{protocol}\r\n" end upgrade << "\r\n" upgrade << challenge_response debug [:upgrade_headers, upgrade] return upgrade end |