Skip to content

Commit 29cf973

Browse files
committed
Fix passing host to in headers
1 parent 961c07c commit 29cf973

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ws4py/client/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ def handshake_headers(self):
253253
handshake.
254254
"""
255255
headers = [
256-
('Host', '%s:%s' % (self.host, self.port)),
257256
('Connection', 'Upgrade'),
258257
('Upgrade', 'websocket'),
259258
('Sec-WebSocket-Key', self.key.decode('utf-8')),
@@ -266,6 +265,10 @@ def handshake_headers(self):
266265
if self.extra_headers:
267266
headers.extend(self.extra_headers)
268267

268+
if not any(x for x in headers if x[0].lower() == 'host') and \
269+
'host' not in self.exclude_headers:
270+
headers.append(('Host', '%s:%s' % (self.host, self.port)))
271+
269272
if not any(x for x in headers if x[0].lower() == 'origin') and \
270273
'origin' not in self.exclude_headers:
271274

0 commit comments

Comments
 (0)