7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/eventmachine/websocket/client.rb', line 7
def post_init
url = @options.fetch(:url)
if url.scheme == "wss"
@secure = true
@tls_options[:sni_hostname] ||= url.host
end
super
@version = 13
@key = SecureRandom.base64(16)
@parser = Http::Parser.new
@parser. = proc do
= @parser.
@parser = nil
accept = Digest::SHA1.base64digest(@key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11")
unless ["Connection"]&.downcase == "upgrade" &&
["Upgrade"]&.downcase == "websocket" &&
["Sec-WebSocket-Accept"] == accept
raise HandshakeError, "Invalid server handshake"
end
debug [:handshake_completed]
@handler = Handler.klass_factory(@version).prepend(ClientFraming).new(self, @debug)
trigger_on_open(_handshake = nil)
:stop
end
send_handshake unless @secure
end
|