Revert "Change the completionhandler to accept Res"
This reverts commit 91995f3272010875e1559397e98ca93354066a0e.
Seeing bumps fail.
https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/48864
Please fix, test, and resubmit.
Change-Id: Id539fe66d5a093caf8f22a393f7af7b58ead5247
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/http/http_response.hpp b/http/http_response.hpp
index c99b2c3..a983d4a 100644
--- a/http/http_response.hpp
+++ b/http/http_response.hpp
@@ -39,8 +39,6 @@
Response() : stringResponse(response_type{})
{}
- Response(Response&& res) = delete;
-
Response& operator=(const Response& r) = delete;
Response& operator=(Response&& r) noexcept
@@ -115,53 +113,37 @@
{
if (completed)
{
- BMCWEB_LOG_ERROR << this << " Response was ended twice";
+ BMCWEB_LOG_ERROR << "Response was ended twice";
return;
}
completed = true;
- BMCWEB_LOG_DEBUG << this << " calling completion handler";
+ BMCWEB_LOG_DEBUG << "calling completion handler";
if (completeRequestHandler)
{
- BMCWEB_LOG_DEBUG << this << " completion handler was valid";
- completeRequestHandler(*this);
+ BMCWEB_LOG_DEBUG << "completion handler was valid";
+ completeRequestHandler();
}
}
+ void end(std::string_view bodyPart)
+ {
+ write(bodyPart);
+ end();
+ }
+
bool isAlive()
{
return isAliveHelper && isAliveHelper();
}
- void setCompleteRequestHandler(std::function<void(Response&)>&& handler)
+ void setCompleteRequestHandler(std::function<void()> newHandler)
{
- BMCWEB_LOG_DEBUG << this << " setting completion handler";
- completeRequestHandler = std::move(handler);
- }
-
- std::function<void(Response&)> releaseCompleteRequestHandler()
- {
- BMCWEB_LOG_DEBUG << this << " releasing completion handler"
- << static_cast<bool>(completeRequestHandler);
- std::function<void(Response&)> ret = completeRequestHandler;
- completeRequestHandler = nullptr;
- return ret;
- }
-
- void setIsAliveHelper(std::function<bool()>&& handler)
- {
- isAliveHelper = std::move(handler);
- }
-
- std::function<bool()> releaseIsAliveHelper()
- {
- std::function<bool()> ret = std::move(isAliveHelper);
- isAliveHelper = nullptr;
- return ret;
+ completeRequestHandler = std::move(newHandler);
}
private:
- bool completed = false;
- std::function<void(Response&)> completeRequestHandler;
+ bool completed{};
+ std::function<void()> completeRequestHandler;
std::function<bool()> isAliveHelper;
// In case of a JSON object, set the Content-Type header