diff --git a/autobahn/websocket/protocol.py b/autobahn/websocket/protocol.py index 9032604c4..8202f2c60 100755 --- a/autobahn/websocket/protocol.py +++ b/autobahn/websocket/protocol.py @@ -2615,7 +2615,7 @@ def processHandshake(self): except ValueError: return self.failHandshake("invalid port '%s' in HTTP Host header '%s'" % (str(p.strip()), str(self.http_request_host))) - # do port checking only if externalPort or URL was set + # do port checking only if externalPort was set if self.factory.externalPort: if port != self.factory.externalPort: return self.failHandshake("port %d in HTTP Host header '%s' does not match server listening port %s" % (port, str(self.http_request_host), self.factory.externalPort)) @@ -2624,14 +2624,6 @@ def processHandshake(self): self.http_request_host = h - else: - # do port checking only if externalPort or URL was set - if self.factory.externalPort: - if not ((self.factory.isSecure and self.factory.externalPort == 443) or (not self.factory.isSecure and self.factory.externalPort == 80)): - return self.failHandshake("missing port in HTTP Host header '%s' and server runs on non-standard port %d (wss = %s)" % (str(self.http_request_host), self.factory.externalPort, self.factory.isSecure)) - else: - self.log.debug("skipping opening handshake port checking - neither WS URL nor external port set") - # Upgrade # if 'upgrade' not in self.http_headers: @@ -3195,12 +3187,7 @@ def setSessionParameters(self, self.server = server self.headers = headers or {} - if externalPort: - self.externalPort = externalPort - elif url: - self.externalPort = self.port - else: - self.externalPort = None + self.externalPort = externalPort def resetProtocolOptions(self): """