From 3dbe0d4ec37fe029f89bec6150747cca5bbde613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Tue, 30 Mar 2021 10:26:42 +0100 Subject: [PATCH] Improve Host HTTP header (#181) ***NO_CI*** --- .../Http/System.Net.HttpWebRequest.cs | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/nanoFramework.System.Net.Http/Http/System.Net.HttpWebRequest.cs b/nanoFramework.System.Net.Http/Http/System.Net.HttpWebRequest.cs index b97b0305..e3804b76 100644 --- a/nanoFramework.System.Net.Http/Http/System.Net.HttpWebRequest.cs +++ b/nanoFramework.System.Net.Http/Http/System.Net.HttpWebRequest.cs @@ -1264,7 +1264,8 @@ private void PrepareHeaders() } } - m_httpRequestHeaders.ChangeInternal(HttpKnownHeaderNames.Host, ConnectHostAndPort()); + m_httpRequestHeaders.ChangeInternal(HttpKnownHeaderNames.Host, m_originalUrl.Host); + // Adds user name and password for basic Http authentication. if (m_NetworkCredentials != null && m_NetworkCredentials.AuthenticationType == AuthenticationType.Basic) { // If credentials are supplied, we need to add header like "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" @@ -1291,22 +1292,6 @@ private void PrepareHeaders() m_requestSent = true; } - /// - /// Return string with remote Host and Port if port is not default. - /// Need update for HTTPS. - /// - /// String with host Url and port corresponding to target Uri. - internal string ConnectHostAndPort() - { - string retStr = m_originalUrl.Host; - if (m_originalUrl.Port != 80) - { - retStr += ":" + m_originalUrl.Port; - } - - return retStr; - } - /// /// Removes the given stream from the connection pool ///