From: Kyle Kelley Date: Thu, 8 May 2014 18:57:39 +0000 (-0500) Subject: Clean up style when rejecting/passing on origin X-Git-Tag: v4.0.0b1~35^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fcbe30b3c47052fd5b57d6c048eab63bb8a6d9d;p=thirdparty%2Ftornado.git Clean up style when rejecting/passing on origin --- diff --git a/tornado/websocket.py b/tornado/websocket.py index e9fa3d2e9..6f552f71d 100644 --- a/tornado/websocket.py +++ b/tornado/websocket.py @@ -154,13 +154,11 @@ class WebSocketHandler(tornado.web.RequestHandler): else: origin = self.request.headers.get("Sec-Websocket-Origin", None) - # When origin is None, assume it didn't come from a browser and we can - # pass it on - if origin is None: - pass + # If there was an origin header, check to make sure it matches - # according to check_origin - elif origin and not self.check_origin(origin): + # according to check_origin. When the origin is None, we assume it + # came from a browser and that it can be passed on. + if origin is not None and not self.check_origin(origin): self.stream.write(tornado.escape.utf8( "HTTP/1.1 403 Cross Origin Websockets Disabled\r\n\r\n" ))