From 29cf973a2b86ecd1156fcf0185148f40a77261b5 Mon Sep 17 00:00:00 2001 From: liuchong Date: Wed, 7 Apr 2021 16:02:06 +0800 Subject: [PATCH 1/2] Fix passing host to in headers --- ws4py/client/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ws4py/client/__init__.py b/ws4py/client/__init__.py index 411638f..f56727d 100644 --- a/ws4py/client/__init__.py +++ b/ws4py/client/__init__.py @@ -253,7 +253,6 @@ def handshake_headers(self): handshake. """ headers = [ - ('Host', '%s:%s' % (self.host, self.port)), ('Connection', 'Upgrade'), ('Upgrade', 'websocket'), ('Sec-WebSocket-Key', self.key.decode('utf-8')), @@ -266,6 +265,10 @@ def handshake_headers(self): if self.extra_headers: headers.extend(self.extra_headers) + if not any(x for x in headers if x[0].lower() == 'host') and \ + 'host' not in self.exclude_headers: + headers.append(('Host', '%s:%s' % (self.host, self.port))) + if not any(x for x in headers if x[0].lower() == 'origin') and \ 'origin' not in self.exclude_headers: From 37c8ec5052d1e143beed807f84d20e4e6eff034a Mon Sep 17 00:00:00 2001 From: Asif Saif Uddin Date: Tue, 24 Dec 2024 15:04:27 +0600 Subject: [PATCH 2/2] Update ws4py/client/__init__.py Signed-off-by: Asif Saif Uddin --- ws4py/client/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ws4py/client/__init__.py b/ws4py/client/__init__.py index f56727d..ec7db8a 100644 --- a/ws4py/client/__init__.py +++ b/ws4py/client/__init__.py @@ -269,6 +269,7 @@ def handshake_headers(self): 'host' not in self.exclude_headers: headers.append(('Host', '%s:%s' % (self.host, self.port))) + if not any(x for x in headers if x[0].lower() == 'origin') and \ 'origin' not in self.exclude_headers: