diff options
author | Damjan Stulic <damjan.stulic@sonos.com> | 2019-08-07 15:26:16 -0700 |
---|---|---|
committer | Damjan Stulic <damjan.stulic@sonos.com> | 2019-08-07 15:26:16 -0700 |
commit | 0598ef1a7a9d72670bf592439f1899412e790989 (patch) | |
tree | b17f0253518062a567c4741a37994a081694d5cd /websocket | |
parent | 3c25814664fef5b78716ed8841123ed1c0d17824 (diff) | |
download | websocket-client-0598ef1a7a9d72670bf592439f1899412e790989.tar.gz |
added support for allowing users to change connection header
Diffstat (limited to 'websocket')
-rw-r--r-- | websocket/_handshake.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/websocket/_handshake.py b/websocket/_handshake.py index 809a8c9..20b950b 100644 --- a/websocket/_handshake.py +++ b/websocket/_handshake.py @@ -95,14 +95,13 @@ def _pack_hostname(hostname): def _get_handshake_headers(resource, host, port, options): headers = [ "GET %s HTTP/1.1" % resource, - "Upgrade: websocket", - "Connection: Upgrade" + "Upgrade: websocket" ] if port == 80 or port == 443: hostport = _pack_hostname(host) else: hostport = "%s:%d" % (_pack_hostname(host), port) - + if "host" in options and options["host"] is not None: headers.append("Host: %s" % options["host"]) else: @@ -126,6 +125,11 @@ def _get_handshake_headers(resource, host, port, options): if not 'header' in options or 'Sec-WebSocket-Version' not in options['header']: headers.append("Sec-WebSocket-Version: %s" % VERSION) + if not 'connection' in options: + headers.append('Connection: upgrade') + else: + headers.append(options['connection']) + subprotocols = options.get("subprotocols") if subprotocols: headers.append("Sec-WebSocket-Protocol: %s" % ",".join(subprotocols)) |