Class: EventMachine::WebSocket::Handler75

Inherits:
Handler
  • Object
show all
Defined in:
lib/em-websocket/handler75.rb

Instance Attribute Summary

Attributes inherited from Handler

#request

Instance Method Summary collapse

Methods inherited from Handler

#initialize

Constructor Details

This class inherits a constructor from EventMachine::WebSocket::Handler

Instance Method Details

#handshakeObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/em-websocket/handler75.rb', line 4

def handshake
  location  = "#{@request['Host'].scheme}://#{@request['Host'].host}"
  location << ":#{@request['Host'].port}" if @request['Host'].port
  location << @request['Path']

  upgrade =  "HTTP/1.1 101 Web Socket Protocol Handshake\r\n"
  upgrade << "Upgrade: WebSocket\r\n"
  upgrade << "Connection: Upgrade\r\n"
  upgrade << "WebSocket-Origin: #{@request['Origin']}\r\n"
  upgrade << "WebSocket-Location: #{location}\r\n\r\n"

  debug [:upgrade_headers, upgrade]

  return upgrade
end