mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 10:18:15 +09:00
LibHTTP: Fix not consuming the last byte of body in from_raw_request
`index + 1` was not correct. For example, if the body has two bytes, we would consume the first byte and increment the index. We then add one to the index and see it's equal to the size, so we take this one byte and set the body result to it. The while loop would still continue and we consume the second byte, adding it to the temporary buffer. We see that the index is above the size, so we don't update the body, dropping the last byte on the floor.
This commit is contained in:
parent
5fcf00f30d
commit
41d6307c17
Notes:
sideshowbarker
2024-07-17 07:06:47 +09:00
Author: https://github.com/Lubrsi
Commit: 41d6307c17
Pull-request: https://github.com/SerenityOS/serenity/pull/15689
Reviewed-by: https://github.com/linusg ✅
1 changed files with 1 additions and 1 deletions
|
@ -175,7 +175,7 @@ Optional<HttpRequest> HttpRequest::from_raw_request(ReadonlyBytes raw_request)
|
|||
break;
|
||||
case State::InBody:
|
||||
buffer.append(consume());
|
||||
if (index + 1 == raw_request.size()) {
|
||||
if (index == raw_request.size()) {
|
||||
// End of data, so store the body
|
||||
auto maybe_body = ByteBuffer::copy(buffer);
|
||||
// FIXME: Propagate this error somehow.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue