Commits

Arkaitz Jimenez committed 99e782e

Fixes headers for Firefox and Chromium

  • Participants
  • Parent commits b92dfc4
  • Branches default

Comments (0)

Files changed (1)

File geventwebsocket/handler.py

         # TODO: refactor to run under run_application
         # In case the client doesn't want to initialize a WebSocket connection
         # we will proceed with the default PyWSGI functionality.
-        if self.environ.get("HTTP_CONNECTION") != "Upgrade" or \
-           self.environ.get("HTTP_UPGRADE") != "WebSocket" or \
-           not self.environ.get("HTTP_ORIGIN") or \
+        if self.environ.get("HTTP_CONNECTION").endswith("Upgrade") or \
+           self.environ.get("HTTP_UPGRADE").lower() != "websocket" or \
+           not self.environ.get("HTTP_SEC_WEBSOCKET_ORIGIN") or \
            not self.accept_upgrade():
-            return super(WebSocketHandler, self).handle_one_response()
+               print "Not!!"
+               return super(WebSocketHandler, self).handle_one_response()
 
         self.websocket = WebSocket(self.socket, self.rfile, self.environ)
         self.environ['wsgi.websocket'] = self.websocket
             super(WebSocketHandler, self).write(data)
 
     def start_response(self, status, headers, exc_info=None):
-        if self.websocket_connection:
+        if self.websocket:
             self.status = status
 
             towrite = []
                 towrite.append("%s: %s\r\n" % header)
 
             towrite.append("\r\n")
-            self.socket.sendall(towrite)
+            self.socket.sendall(str(towrite))
             self.headers_sent = True
         else:
             super(WebSocketHandler, self).start_response(status, headers, exc_info)