diff --git a/libraries/HTTPClient/src/HTTPClient.cpp b/libraries/HTTPClient/src/HTTPClient.cpp index b1328c07316..d2722205898 100644 --- a/libraries/HTTPClient/src/HTTPClient.cpp +++ b/libraries/HTTPClient/src/HTTPClient.cpp @@ -1423,7 +1423,7 @@ int HTTPClient::writeToStreamDataBlock(Stream * stream, int size) // some time for the stream delay(1); - int leftBytes = (readBytes - bytesWrite); + int leftBytes = (bytesRead - bytesWrite); // retry to send the missed bytes bytesWrite = stream->write((buff + bytesWrite), leftBytes); @@ -1446,7 +1446,7 @@ int HTTPClient::writeToStreamDataBlock(Stream * stream, int size) // count bytes to read left if(len > 0) { - len -= readBytes; + len -= bytesRead; } delay(0);