summaryrefslogtreecommitdiff
path: root/include/async_resp.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-07-22 19:50:44 +0300
committerEd Tanous <ed@tanous.net>2022-08-04 18:45:37 +0300
commit13548d8598b164684d40f62d6a875f164593f509 (patch)
tree5631a9888882072b84abe5e4db531eaae3537cce /include/async_resp.hpp
parentaefe3786057499a767c5627b0106f0248fa3762d (diff)
downloadbmcweb-13548d8598b164684d40f62d6a875f164593f509.tar.xz
Preserve headers from the root object on expand
There is a bug where, when running an expand query, headers from the response object get dropped. These headers include OData.type, and the newly minted Link header, as well as possible others. This was actually noted in a TODO, although the author of the TODO, didn't fully understand the consequences at the time, and thought there was no functional impact. To resolve this, this commit resolves the TODO, and allows the Response object to be moved out, instead of having to create a new one, which preserves all the response state. To do this, it creates a move constructor on the Response object for this use. The move constructor is relatively benign, with one caveat, that we might be moving while in a completion handler (as is the most common use). So both the existing operator= and Response() move constructor are amended to handle this case, and simply null out the response object in the copied object, which would be correct behavior, given that each callback handler should only be called once per Response object. Tested: curl --insecure --user root:0penBmc -vvvv https://192.168.7.2/redfish/v1\?\$expand\=\*\(\$levels\=2\) returns the same body as previously, now with the included: OData-Version: 4.0 Allow: Get headers in the response. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I221364dd4304903b37cacb1386f621b073a0a891
Diffstat (limited to 'include/async_resp.hpp')
-rw-r--r--include/async_resp.hpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/async_resp.hpp b/include/async_resp.hpp
index 219d9df796..d7f5819142 100644
--- a/include/async_resp.hpp
+++ b/include/async_resp.hpp
@@ -16,6 +16,8 @@ class AsyncResp
{
public:
AsyncResp() = default;
+ explicit AsyncResp(crow::Response&& resIn) : res(std::move(resIn))
+ {}
AsyncResp(const AsyncResp&) = delete;
AsyncResp(AsyncResp&&) = delete;