Skip to content

Commit b8698c9

Browse files
committed
Fix length passed to callback
The calculated len was not taking in consideration the remaining bytes to send when a content-length was set.
1 parent 079139a commit b8698c9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/WebResponses.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,8 @@ size_t AsyncAbstractResponse::write_send_buffs(AsyncWebServerRequest *request, s
470470
}
471471
}
472472
} else {
473-
size_t const readLen = _fillBufferAndProcessTemplates(_send_buffer->data(), std::min(_send_buffer->size(), tcp_win));
473+
size_t const readLen =
474+
_fillBufferAndProcessTemplates(_send_buffer->data(), std::min(std::min(_send_buffer->size(), tcp_win), _contentLength - _sentLength));
474475
if (readLen == 0) {
475476
// no more data to send
476477
_state = RESPONSE_END;

0 commit comments

Comments
 (0)