Module: Async::WebSocket::Adapters::Rack
- Includes:
- Protocol::WebSocket::Headers
- Defined in:
- lib/async/websocket/adapters/rack.rb
Class Method Summary collapse
Class Method Details
.open(env, **options, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/async/websocket/adapters/rack.rb', line 35 def self.open(env, **, &block) if request = env['async.http.request'] env = nil if response = HTTP.open(request, **, &block) headers = response.headers if protocol = response.protocol headers = Protocol::HTTP::Headers::Merged.new(headers, [ ['rack.protocol', protocol] ]) end return [response.status, headers.to_h, response.body] end end end |
.websocket?(env) ⇒ Boolean
31 32 33 |
# File 'lib/async/websocket/adapters/rack.rb', line 31 def self.websocket?(env) request = env['async.http.request'] and Array(request.protocol).include?(PROTOCOL) end |