mirror of
https://github.com/arendst/Tasmota.git
synced 2026-10-26 22:11:22 +00:00
AsyncHttpClientLight: finish a chunked body at the empty line after the last chunk (#25142)
After the zero-size chunk the readers read one line unconditionally, then waited for another empty line. The first read already consumed the empty line that ends the body, so every chunked body waited for a line that never came and failed with HTTPC_ERROR_READ_TIMEOUT after _tcpTimeout. Read trailer lines up to the first empty one instead.
This commit is contained in:
1 parent
770960cec8
commit
90754c5b93
1 file changed
+3
-14
@@ -1022,12 +1022,7 @@ int AsyncHttpClientLight::Job_WriteToStream(void* arg) {
|
||||
int chunk = (int) strtol(h.c_str(), nullptr, 16);
|
||||
|
||||
if (chunk <= 0) {
|
||||
String tmp;
|
||||
if (!readLine(tmp)) {
|
||||
if (a->self->_transport) a->self->_transport->stop();
|
||||
a->self->_bodyPending = false;
|
||||
return HTTPC_ERROR_READ_TIMEOUT;
|
||||
}
|
||||
// after the last chunk: trailer lines, if any, up to an empty line
|
||||
while (true) {
|
||||
String t;
|
||||
if (!readLine(t)) {
|
||||
@@ -1143,12 +1138,7 @@ int AsyncHttpClientLight::Job_GetString(void* arg) {
|
||||
int chunk = (int) strtol(h.c_str(), nullptr, 16);
|
||||
|
||||
if (chunk <= 0) {
|
||||
String tmp;
|
||||
if (!readLine(tmp)) {
|
||||
if (a->self->_transport) a->self->_transport->stop();
|
||||
a->self->_bodyPending = false;
|
||||
return HTTPC_ERROR_READ_TIMEOUT;
|
||||
}
|
||||
// after the last chunk: trailer lines, if any, up to an empty line
|
||||
while (true) {
|
||||
String t;
|
||||
if (!readLine(t)) {
|
||||
@@ -1296,8 +1286,7 @@ int AsyncHttpClientLight::readBodyToStreamString(StreamString& s, int size_limit
|
||||
h.trim();
|
||||
int chunk = (int) strtol(h.c_str(), nullptr, 16);
|
||||
if (chunk <= 0) {
|
||||
String tmp;
|
||||
if (!readLine(tmp)) return bail(HTTPC_ERROR_READ_TIMEOUT);
|
||||
// after the last chunk: trailer lines, if any, up to an empty line
|
||||
while (true) { String t; if (!readLine(t)) return bail(HTTPC_ERROR_READ_TIMEOUT); if (t.length() == 0) break; }
|
||||
break; // end
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user