]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Move origin parsing in to check_origin
authorKyle Kelley <kyle.kelley@rackspace.com>
Tue, 25 Feb 2014 02:32:36 +0000 (20:32 -0600)
committerKyle Kelley <kyle.kelley@rackspace.com>
Thu, 8 May 2014 18:42:21 +0000 (13:42 -0500)
tornado/websocket.py

index 94164de56a88928e40deb3f63b8ec08659618c2b..e9fa3d2e97a315a7e610ec74e3c0911653e5c7b6 100644 (file)
@@ -154,16 +154,6 @@ class WebSocketHandler(tornado.web.RequestHandler):
         else:
             origin = self.request.headers.get("Sec-Websocket-Origin", None)
 
-        # If we have an origin, normalize
-        if(origin):
-            # Due to how stdlib's urlparse is implemented, urls without a //
-            # are interpreted to be paths (resulting in netloc being None)
-            if("//" not in origin):
-                origin = "//" + origin
-            parsed_origin = urlparse(origin)
-            origin = parsed_origin.netloc
-            origin = origin.lower()
-
         # When origin is None, assume it didn't come from a browser and we can
         # pass it on
         if origin is None:
@@ -296,6 +286,14 @@ class WebSocketHandler(tornado.web.RequestHandler):
         browsers, since WebSockets don't have CORS headers.
         """
 
+        # Due to how stdlib's urlparse is implemented, urls without a //
+        # are interpreted to be paths (resulting in netloc being None)
+        if("//" not in origin):
+            origin = "//" + origin
+        parsed_origin = urlparse(origin)
+        origin = parsed_origin.netloc
+        origin = origin.lower()
+
         host = self.request.headers.get("Host")
 
         # Check to see that origin matches host directly, including ports