diff options
| author | liris <liris.pp@gmail.com> | 2018-08-14 14:56:46 +0900 |
|---|---|---|
| committer | liris <liris.pp@gmail.com> | 2018-08-14 14:56:46 +0900 |
| commit | 038e002ff90205755d5eb35cd9036bd39b0eec62 (patch) | |
| tree | 89d9c6dcf8f4d922ca8426e9b62704cf60bd1da5 | |
| parent | 05ab494f70bd71c461a6b98330af21db3f0abe0f (diff) | |
| download | websocket-client-038e002ff90205755d5eb35cd9036bd39b0eec62.tar.gz | |
fixed #HC-459
| -rw-r--r-- | ChangeLog | 1 | ||||
| -rw-r--r-- | websocket/_app.py | 6 | ||||
| -rw-r--r-- | websocket/_core.py | 2 | ||||
| -rw-r--r-- | websocket/_handshake.py | 9 |
4 files changed, 12 insertions, 6 deletions
@@ -4,6 +4,7 @@ ChangeLog - 0.49.0 - WebSocketApp class to make it inheritable (#442) + - Add option to disable sending the Origin header (#459) - 0.48.0 diff --git a/websocket/_app.py b/websocket/_app.py index f31ad8f..b52aff7 100644 --- a/websocket/_app.py +++ b/websocket/_app.py @@ -177,7 +177,8 @@ class WebSocketApp(object): http_proxy_host=None, http_proxy_port=None, http_no_proxy=None, http_proxy_auth=None, skip_utf8_validation=False, - host=None, origin=None, dispatcher=None): + host=None, origin=None, dispatcher=None, + supress_origin = False): """ run event loop for WebSocket framework. This loop is infinite loop and is alive during websocket is available. @@ -195,6 +196,7 @@ class WebSocketApp(object): skip_utf8_validation: skip utf8 validation. host: update host header. origin: update origin header. + "supress_origin" -> suppress outputting origin header. """ if not ping_timeout or ping_timeout <= 0: @@ -235,7 +237,7 @@ class WebSocketApp(object): http_proxy_host=http_proxy_host, http_proxy_port=http_proxy_port, http_no_proxy=http_no_proxy, http_proxy_auth=http_proxy_auth, subprotocols=self.subprotocols, - host=host, origin=origin) + host=host, origin=origin, supress_origin = supress_origin) if not dispatcher: dispatcher = self.create_dispatcher(ping_timeout) diff --git a/websocket/_core.py b/websocket/_core.py index 2d00962..04d909d 100644 --- a/websocket/_core.py +++ b/websocket/_core.py @@ -201,6 +201,7 @@ class WebSocket(object): options: "header" -> custom http header list or dict. "cookie" -> cookie value. "origin" -> custom origin url. + "supress_origin" -> suppress outputting origin header. "host" -> custom host header string. "http_proxy_host" - http proxy host name. "http_proxy_port" - http proxy port. If not set, set to 80. @@ -466,6 +467,7 @@ def create_connection(url, timeout=None, class_=WebSocket, **options): options: "header" -> custom http header list or dict. "cookie" -> cookie value. "origin" -> custom origin url. + "supress_origin" -> suppress outputting origin header. "host" -> custom host header string. "http_proxy_host" - http proxy host name. "http_proxy_port" - http proxy port. If not set, set to 80. diff --git a/websocket/_handshake.py b/websocket/_handshake.py index 3fd5c9e..242b0be 100644 --- a/websocket/_handshake.py +++ b/websocket/_handshake.py @@ -96,10 +96,11 @@ def _get_handshake_headers(resource, host, port, options): else: headers.append("Host: %s" % hostport) - if "origin" in options and options["origin"] is not None: - headers.append("Origin: %s" % options["origin"]) - else: - headers.append("Origin: http://%s" % hostport) + if "suppress_origin" not in options or not options["suppress_origin"]: + if "origin" in options and options["origin"] is not None: + headers.append("Origin: %s" % options["origin"]) + else: + headers.append("Origin: http://%s" % hostport) key = _create_sec_websocket_key() headers.append("Sec-WebSocket-Key: %s" % key) |
