Skip to content

Commit

Permalink
powermeter refactor: use HTTP1.0
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
schlimmchen committed Jun 27, 2024
1 parent 15b6a32 commit db869a1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/HttpGetter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit db869a1

Please sign in to comment.