powermeter refactor: use HTTP1.0

avoid problems with chunked transfer encoding when using the client's
stream to parse a JSON document. fixes the HTTP+JSON power meter to work
with shelly and hichi (Tasmota).
This commit is contained in:
Bernhard Kirchen 2024-05-31 13:17:28 +02:00
parent 15b6a32b92
commit db869a1144

View File

@ -101,6 +101,11 @@ HttpRequestResult HttpGetter::performGetRequest()
}
auto upTmpHttpClient = std::make_unique<HTTPClient>();
// use HTTP1.0 to avoid problems with chunked transfer encoding when the
// stream is later used to read the server's response.
upTmpHttpClient->useHTTP10(true);
if (!upTmpHttpClient->begin(*_spWiFiClient, ipaddr.toString(), _port, _uri, _useHttps)) {
logError("HTTP client begin() failed for %s://%s",
(_useHttps ? "https" : "http"), _host.c_str());