Port 443 is also a default port and should be excluded from the Host header on websocket requests for compatibility reasons

This commit is contained in:
David Burhans 2015-06-03 11:15:02 -06:00
parent fbcf8377d3
commit c6e3e12aaf

View File

@ -133,7 +133,8 @@ namespace WebSocketSharp
var headers = req.Headers;
headers["Upgrade"] = "websocket";
headers["Connection"] = "Upgrade";
headers["Host"] = uri.Port == 80 ? uri.DnsSafeHost : uri.Authority;
bool isDefaultPort = (uri.Port == 80 && uri.Scheme == "ws") || (uri.Port == 443 && uri.Scheme == "wss");
headers["Host"] = isDefaultPort ? uri.DnsSafeHost : uri.Authority;
return req;
}