1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

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

Response bodies are ignored when _transferEncoding == HTTPC_TE_IDENTITY and there is no Content-Length header.  The added code here fixes that issue.

Add logic to writeToStreamDataBlock to only read what's available so as to avoid timeout, and adjust formatting.
This commit is contained in:
drderiv 2020-11-20 15:23:43 -08:00 committed by GitHub
parent 27b54f57bd
commit 47a57e1ec6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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?
@ -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);