From 26746df1cf8669547b8a2cf3e3cea837a06a4a58 Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Wed, 15 Dec 2021 13:43:37 +0100 Subject: [PATCH] httpClient: prevent empty user-agent in header --- libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp index 7c52ed8486..2987e2601d 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp @@ -929,8 +929,10 @@ bool HTTPClient::sendHeader(const char * type) header += ':'; header += String(_port); } - header += F("\r\nUser-Agent: "); - header += _userAgent; + if (_userAgent.length()) { + header += F("\r\nUser-Agent: "); + header += _userAgent; + } if (!_useHTTP10) { header += F("\r\nAccept-Encoding: identity;q=1,chunked;q=0.1,*;q=0");