Skip to content

Commit 76e322f

Browse files
committed
Fix handling of chunked transfer encoding (#1975)
1 parent edaae2c commit 76e322f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,13 @@ int HTTPClient::writeToStream(Stream * stream)
624624
break;
625625
}
626626

627+
// read trailing \r\n at the end of the chunk
628+
char buf[2];
629+
auto trailing_seq_len = _tcp->readBytes((uint8_t*)buf, 2);
630+
if (trailing_seq_len != 2 || buf[0] != '\r' || buf[1] != '\n') {
631+
return returnError(HTTPC_ERROR_READ_TIMEOUT);
632+
}
633+
627634
delay(0);
628635
}
629636
} else {

0 commit comments

Comments
 (0)