summaryrefslogtreecommitdiff
path: root/include/async_resp.hpp
diff options
context:
space:
mode:
authorNan Zhou <nanzhoumails@gmail.com>2022-01-28 04:06:51 +0300
committerEd Tanous <ed@tanous.net>2022-03-01 02:30:04 +0300
commit72374eb7fe42257e866dd088bc13520b0b28cffa (patch)
treee3245cf0282b19fc7d2e50300e7dfc41229b6d62 /include/async_resp.hpp
parenta94ac61f69fd3768cf609adc75cfd646c558eb7e (diff)
downloadbmcweb-72374eb7fe42257e866dd088bc13520b0b28cffa.tar.xz
Change the completionhandler to accept Res
These modifications are from WIP:Redfish:Query parameters:Only (https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/47474). It will be used in future CLs for Query Parameters. The code changed the completion handle to accept Res to be able to recall handle with a new Response object. AsyncResp owns a new res, so there is no need to pass in a res. Also fixed a self-move assignment bug. Context: Originally submitted: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/480020 Reveted here: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/48880 Because of failures here: https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/48864 Tested: 1. Romulus QEMU + Robot tests; all passed 2. Use scripts/websocket_test.py to test websockets. It is still work correctly. 3. Tested in real hardware; no new validator errors; tested both authless, session, and basic auth. 4. Hacked codes to return 500 errors on certain resource; response is expected; 5. Tested Eventing, the push style one (not SSE which is still under review), worked as expected. 6. Tested 404 errors; response is expected. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Signed-off-by: John Edward Broadbent <jebr@google.com> Change-Id: I52adb174476e0f6656335baa6657456752a031be
Diffstat (limited to 'include/async_resp.hpp')
-rw-r--r--include/async_resp.hpp15
1 files changed, 2 insertions, 13 deletions
diff --git a/include/async_resp.hpp b/include/async_resp.hpp
index 607d168e9e..219d9df796 100644
--- a/include/async_resp.hpp
+++ b/include/async_resp.hpp
@@ -15,12 +15,7 @@ namespace bmcweb
class AsyncResp
{
public:
- AsyncResp(crow::Response& response) : res(response)
- {}
-
- AsyncResp(crow::Response& response, std::function<void()>&& function) :
- res(response), func(std::move(function))
- {}
+ AsyncResp() = default;
AsyncResp(const AsyncResp&) = delete;
AsyncResp(AsyncResp&&) = delete;
@@ -29,16 +24,10 @@ class AsyncResp
~AsyncResp()
{
- if (func && res.result() == boost::beast::http::status::ok)
- {
- func();
- }
-
res.end();
}
- crow::Response& res;
- std::function<void()> func;
+ crow::Response res;
};
} // namespace bmcweb