From c6e3e12aaf581ab6e6bc5b73541d961992d8d613 Mon Sep 17 00:00:00 2001 From: David Burhans Date: Wed, 3 Jun 2015 11:15:02 -0600 Subject: [PATCH] Port 443 is also a default port and should be excluded from the Host header on websocket requests for compatibility reasons --- websocket-sharp/HttpRequest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 41f700e2..d7c2c842 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -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; }