Class: Faye::WebSocket::Draft76Parser

Inherits:
Draft75Parser show all
Defined in:
lib/faye/util/web_socket/draft76_parser.rb

Instance Method Summary collapse

Methods inherited from Draft75Parser

#frame, #initialize, #parse

Constructor Details

This class inherits a constructor from Faye::WebSocket::Draft75Parser

Instance Method Details

#handshake_responseObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/faye/util/web_socket/draft76_parser.rb', line 9

def handshake_response
  env = @socket.env
  
  key1   = env['HTTP_SEC_WEBSOCKET_KEY1']
  value1 = number_from_key(key1) / spaces_in_key(key1)
  
  key2   = env['HTTP_SEC_WEBSOCKET_KEY2']
  value2 = number_from_key(key2) / spaces_in_key(key2)
  
  hash = Digest::MD5.digest(big_endian(value1) +
                            big_endian(value2) +
                            env['rack.input'].read)
  
  upgrade =  "HTTP/1.1 101 Web Socket Protocol Handshake\r\n"
  upgrade << "Upgrade: WebSocket\r\n"
  upgrade << "Connection: Upgrade\r\n"
  upgrade << "Sec-WebSocket-Origin: #{env['HTTP_ORIGIN']}\r\n"
  upgrade << "Sec-WebSocket-Location: #{@socket.url}\r\n"
  upgrade << "\r\n"
  upgrade << hash
  upgrade
end

#versionObject



5
6
7
# File 'lib/faye/util/web_socket/draft76_parser.rb', line 5

def version
  'draft-76'
end