diff --git a/ws4py/client/__init__.py b/ws4py/client/__init__.py index 411638f..ec7db8a 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,11 @@ 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: