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>
diff --git a/http/http_body.hpp b/http/http_body.hpp
index 4b58f21..f2ec53f 100644
--- a/http/http_body.hpp
+++ b/http/http_body.hpp
@@ -117,6 +117,7 @@
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 afd51c1..c93d60d 100644
--- a/http/http_response.hpp
+++ b/http/http_response.hpp
@@ -190,6 +190,7 @@
{
BMCWEB_LOG_DEBUG("{} Clearing response containers", logPtr(this));
response.clear();
+ response.body().clear();
jsonValue = nullptr;
completed = false;