From 477e74d18750ec1c0f0d6f398e64c1eb0d12059f Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Sat, 29 Oct 2022 12:23:15 +0100 Subject: [PATCH] NetServices: fix parsing raw HTTP bodies without a known size When parsing a raw HTTP body without a known size, whether or not a request is complete depends on the end of the connection. Make sure that the parser updates to complete when all the bytes in the buffer have been read and the connection closed. Change-Id: I6f055b43ffe4a44da65da85c19b71304d804c800 --- src/kits/network/libnetservices2/HttpParser.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/kits/network/libnetservices2/HttpParser.cpp b/src/kits/network/libnetservices2/HttpParser.cpp index 12b05601a3..8b9b2fb25e 100644 --- a/src/kits/network/libnetservices2/HttpParser.cpp +++ b/src/kits/network/libnetservices2/HttpParser.cpp @@ -354,10 +354,13 @@ HttpRawBodyParser::ParseBody(HttpBuffer& buffer, HttpTransferFunction writeToBod "Could not write all available body bytes to the target."); } - if (fBodyBytesTotal && *fBodyBytesTotal == fTransferredBodySize) - return {bytesRead, bytesRead, true}; - else - return {bytesRead, bytesRead, false}; + if (fBodyBytesTotal) { + if (*fBodyBytesTotal == fTransferredBodySize) + return {bytesRead, bytesRead, true}; + else + return {bytesRead, bytesRead, false}; + } else + return {bytesRead, bytesRead, readEnd}; }