Skip to content

Commit

Permalink
Improve Host HTTP header (#181)
Browse files Browse the repository at this point in the history
***NO_CI***
  • Loading branch information
josesimoes authored Mar 30, 2021
1 parent a159ab6 commit 3dbe0d4
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions nanoFramework.System.Net.Http/Http/System.Net.HttpWebRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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=="
Expand All @@ -1291,22 +1292,6 @@ private void PrepareHeaders()
m_requestSent = true;
}

/// <summary>
/// Return string with remote Host and Port if port is not default.
/// Need update for HTTPS.
/// </summary>
/// <returns>String with host Url and port corresponding to target Uri.</returns>
internal string ConnectHostAndPort()
{
string retStr = m_originalUrl.Host;
if (m_originalUrl.Port != 80)
{
retStr += ":" + m_originalUrl.Port;
}

return retStr;
}

/// <summary>
/// Removes the given stream from the connection pool
/// </summary>
Expand Down

0 comments on commit 3dbe0d4

Please sign in to comment.