8000 Movable HTTPClient and fixing WiFiClient copy by mcspr · Pull Request #8237 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

Movable HTTPClient and fixing WiFiClient copy #8237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 13, 2021
Prev Previous commit
Next Next commit
initialize with default user agent but never reset it back
  • Loading branch information
mcspr committed Jul 24, 2021
commit 8e267554625c8892b69d52fcc49f261dea3f927e
9 changes: 3 additions & 6 deletions libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ static_assert(!std::is_copy_constructible_v<HTTPClient>, "");
static_assert(std::is_move_constructible_v<HTTPClient>, "");
static_assert(std::is_move_assignable_v<HTTPClient>, "");

static const char defaultUserAgent[] PROGMEM = "ESP8266HTTPClient";
static const char defaultUserAgentPstr[] PROGMEM = "ESP8266HTTPClient";
const String HTTPClient::defaultUserAgent = defaultUserAgentPstr;

static int StreamReportToHttpClientReport (Stream::Report streamSendError)
{
Expand Down Expand Up @@ -900,11 +901,7 @@ bool HTTPClient::sendHeader(const char * type)
header += String(_port);
}
header += F("\r\nUser-Agent: ");
if (!_userAgent.length()) {
header += defaultUserAgent;
} else {
header += _userAgent;
}
header += _userAgent;

if (!_useHTTP10) {
header += F("\r\nAccept-Encoding: identity;q=1,chunked;q=0.1,*;q=0");
Expand Down
4 changes: 3 additions & 1 deletion libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,11 @@ class HTTPClient
String _uri;
String _protocol;
String _headers;
String _userAgent;
String _base64Authorization;

static const String defaultUserAgent;
String _userAgent = defaultUserAgent;

/// Response handling
std::unique_ptr<RequestArgument[]> _currentHeaders;
size_t _headerKeysCount = 0;
Expand Down
0