# File lib/ftw/websocket/rack.rb, line 31 def initialize(rack_env) @env = rack_env @handshake_errors = [] # RFC6455 section 4.2.1 bullet 3 expect_equal("websocket", @env["HTTP_UPGRADE"], "The 'Upgrade' header must be set to 'websocket'") # RFC6455 section 4.2.1 bullet 4 # Firefox uses a multivalued 'Connection' header, that appears like this: # Connection: keep-alive, Upgrade # So we have to split this multivalue field. expect_equal(true, @env["HTTP_CONNECTION"].split(/, +/).include?("Upgrade"), "The 'Connection' header must be set to 'Upgrade'") # RFC6455 section 4.2.1 bullet 6 expect_equal("13", @env["HTTP_SEC_WEBSOCKET_VERSION"], "Sec-WebSocket-Version must be set to 13") # RFC6455 section 4.2.1 bullet 5 @key = @env["HTTP_SEC_WEBSOCKET_KEY"] @parser = FTW::WebSocket::Parser.new end