36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/async/websocket/adapters/rack.rb', line 36
def self.open(env, headers: [], protocols: [], handler: Connection, **options, &block)
if request = env['async.http.request'] and Array(request.protocol).include?(PROTOCOL)
env = nil
if requested_protocol = request.[SEC_WEBSOCKET_PROTOCOL]
protocol = (requested_protocol & protocols).first
end
response = Response.for(request, , protocol: protocol, **options) do |stream|
response = nil
framer = Protocol::WebSocket::Framer.new(stream)
connection = handler.call(framer, protocol)
yield connection
connection.close unless connection.closed?
end
request = nil
= response.
if protocol = response.protocol
= Protocol::HTTP::Headers::Merged.new(, [
['rack.protocol', protocol]
])
end
return [response.status, , response.body]
end
end
|