summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliris <liris.pp@gmail.com>2019-12-25 21:22:32 +0900
committerGitHub <noreply@github.com>2019-12-25 21:22:32 +0900
commit6d1434230510323a43691009b1d0aa3f8a6df132 (patch)
tree4d4d9ea4e77feb0656390ec536d38d94b55a67d2
parent0b99f62e2871df0d498fd324d5b9b629a4b4ee9f (diff)
parent58c05a9283b128372d31715a2d9a1046f9806af7 (diff)
downloadwebsocket-client-6d1434230510323a43691009b1d0aa3f8a6df132.tar.gz
Merge pull request #566 from damjanstulicsonos/expose-http-connection-header-to-user
Expose http connection header to user
-rw-r--r--websocket/_handshake.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/websocket/_handshake.py b/websocket/_handshake.py
index 809a8c9..3ff5147 100644
--- a/websocket/_handshake.py
+++ b/websocket/_handshake.py
@@ -95,14 +95,12 @@ 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 +124,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 or options['connection'] is None:
+ headers.append('Connection: upgrade')
+ else:
+ headers.append(options['connection'])
+
subprotocols = options.get("subprotocols")
if subprotocols:
headers.append("Sec-WebSocket-Protocol: %s" % ",".join(subprotocols))