Skip to content
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

Update to ESP8266HTTPClient.cpp for no Content-Length #7691

Merged
merged 9 commits into from
Nov 20, 2020
8 changes: 7 additions & 1 deletion libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ int HTTPClient::writeToStream(Stream * stream)
int ret = 0;

if(_transferEncoding == HTTPC_TE_IDENTITY) {
if(len > 0) {
if(len > 0 || len == -1) {
ret = writeToStreamDataBlock(stream, len);

// have we an error?
drderiv marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -1184,6 +1184,12 @@ int HTTPClient::writeToStreamDataBlock(Stream * stream, int size)
if(readBytes > buff_size) {
readBytes = buff_size;
}

// len == -1 or len > what is available, read only what is available
int av = _client->available();
if (readBytes < 0 || readBytes > av) {
readBytes = av;
}

// read data
int bytesRead = _client->readBytes(buff, readBytes);
Expand Down