fix(webserver): Cap size of last chunk in raw read in WebServer
Before, the raw read would time out if the content length was not a multiple of HTTP_RAW_BUFLEN, as it tried to read HTTP_RAW_BUFLEN bytes even if the last chunk should actually contain less.
This commit is contained in:
parent
fb6e977aa8
commit
784ef0f286
1 changed files with 6 additions and 2 deletions
|
|
@ -186,8 +186,12 @@ bool WebServer::_parseRequest(NetworkClient &client) {
|
||||||
_currentHandler->raw(*this, _currentUri, *_currentRaw);
|
_currentHandler->raw(*this, _currentUri, *_currentRaw);
|
||||||
_currentRaw->status = RAW_WRITE;
|
_currentRaw->status = RAW_WRITE;
|
||||||
|
|
||||||
while (_currentRaw->totalSize < _clientContentLength) {
|
while (1) {
|
||||||
_currentRaw->currentSize = client.readBytes(_currentRaw->buf, HTTP_RAW_BUFLEN);
|
size_t read_len = std::min(_clientContentLength - _currentRaw->totalSize, (size_t) HTTP_RAW_BUFLEN);
|
||||||
|
if (read_len == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_currentRaw->currentSize = client.readBytes(_currentRaw->buf, read_len);
|
||||||
_currentRaw->totalSize += _currentRaw->currentSize;
|
_currentRaw->totalSize += _currentRaw->currentSize;
|
||||||
if (_currentRaw->currentSize == 0) {
|
if (_currentRaw->currentSize == 0) {
|
||||||
_currentRaw->status = RAW_ABORTED;
|
_currentRaw->status = RAW_ABORTED;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue