Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ bool HTTPClient::begin(WiFiClient &client, const String& host, uint16_t port, co
return true;
}

void HTTPClient::setHostHeader(const String& host) {
_hostHeader = host;
}

bool HTTPClient::beginInternal(const String& __url, const char* expectedProtocol)
{
Expand Down Expand Up @@ -840,7 +843,7 @@ bool HTTPClient::sendHeader(const char * type)
}

header += F("\r\nHost: ");
header += _host;
header += _hostHeader.isEmpty() ? _host : _hostHeader;
if (_port != 80 && _port != 443)
{
header += ':';
Expand Down
2 changes: 2 additions & 0 deletions libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class HTTPClient
void setAuthorization(const char * auth);
void setAuthorization(String auth);
void setTimeout(uint16_t timeout);
void setHostHeader(const String& host);

// Redirections
void setFollowRedirects(followRedirects_t follow);
Expand Down Expand Up @@ -254,6 +255,7 @@ class HTTPClient

/// request handling
String _host;
String _hostHeader;
uint16_t _port = 0;
bool _reuse = true;
uint16_t _tcpTimeout = HTTPCLIENT_DEFAULT_TCP_TIMEOUT;
Expand Down