Skip to content

Commit 61cc420

Browse files
committed
Merge pull request #2006 from b-pass/client-fix
Include non-standard ports in HTTPClient's Host header
2 parents a2b82ed + 74bd4f9 commit 61cc420

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,13 @@ bool HTTPClient::sendHeader(const char * type)
844844
header += "1";
845845
}
846846

847-
header += String(F("\r\nHost: ")) + _host +
848-
F("\r\nUser-Agent: ") + _userAgent +
847+
header += String(F("\r\nHost: ")) + _host;
848+
if (_port != 80 && _port != 443)
849+
{
850+
header += ':';
851+
header += String(_port);
852+
}
853+
header += String(F("\r\nUser-Agent: ")) + _userAgent +
849854
F("\r\nConnection: ");
850855

851856
if(_reuse) {

0 commit comments

Comments
 (0)