summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-03-28 05:58:11 +0300
committerEd Tanous <ed@tanous.net>2024-04-01 19:06:04 +0300
commit06fc9bebd8c9146636b53f2a04d340230bf21e29 (patch)
treea5db592c1d3f7a22538cdcdd44aab5f45df85bdd /http
parentf933a6a0945c6c698ff73c8d59c0153c2387e35b (diff)
downloadbmcweb-06fc9bebd8c9146636b53f2a04d340230bf21e29.tar.xz
Fix regression in http_file_body
The commit: b5f288d Make use of filebody for dump offload Caused a minor failure in clearing responses, where open file handles wouldn't be closed in between queries, resulting in the next read to return empty content. This caused redfish protocol validator to fail. boost::beast::http::response::clear() documentation shows that it only clears the headers, not the file body. Now normally, this doesn't matter, because bmcweb completely replaces the response body when a new response is driven, but not in the case of files. Add response.body().clear() during the clear to ensure the response is cleared. In addition, add encodingType to the clear() call, to ensure that it is reset as well. This is a bug, but I don't know the reproduction steps. Tested: Redfish protocol validator now completes (with SSE failures) Change-Id: Ice6d5085003034a1bed48397ddc6316e9cd0536f Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'http')
-rw-r--r--http/http_body.hpp1
-rw-r--r--http/http_response.hpp1
2 files changed, 2 insertions, 0 deletions
diff --git a/http/http_body.hpp b/http/http_body.hpp
index 4b58f213b1..f2ec53fec2 100644
--- a/http/http_body.hpp
+++ b/http/http_body.hpp
@@ -117,6 +117,7 @@ class HttpBody::value_type
strBody.shrink_to_fit();
fileHandle = boost::beast::file_posix();
fileSize = std::nullopt;
+ encodingType = EncodingType::Raw;
}
void open(const char* path, boost::beast::file_mode mode,
diff --git a/http/http_response.hpp b/http/http_response.hpp
index afd51c1420..c93d60d685 100644
--- a/http/http_response.hpp
+++ b/http/http_response.hpp
@@ -190,6 +190,7 @@ struct Response
{
BMCWEB_LOG_DEBUG("{} Clearing response containers", logPtr(this));
response.clear();
+ response.body().clear();
jsonValue = nullptr;
completed = false;