Trace URI when body on 204/304
Trace URI on the existing CRITICAL message when a body exists but HTTP
return code was Informational responses (100 – 199), no-content (204),
or not_modified (304).
Tested: With these changes, the URI is traced on the CRITICAL message:
```
curl --http2 -k -H "Content-Type: application/json" \
-d '{"PowerRestorePolicy":"LastState"}' \
-X PATCH https://${bmc}/redfish/v1/Systems/system
root@p10bmc:~# journalctl | grep Response
Jun 20 15:30:46 p10bmc bmcwebd[296]: [http_response.hpp:213]
0x1353670 Response content provided but code was no-content
or not_modified, which aren't allowed to
have a body for url : "/redfish/v1/Systems/system"
```
Change-Id: I1ef618600642d355fc9f935d055b011e044caf5c
Signed-off-by: Abiola Asojo <abiola.asojo@ibm.com>
diff --git a/http/http_connection.hpp b/http/http_connection.hpp
index 0c8ad0e..5001c9e 100644
--- a/http/http_connection.hpp
+++ b/http/http_connection.hpp
@@ -41,6 +41,7 @@
#include <boost/beast/http/verb.hpp>
#include <boost/none.hpp>
#include <boost/optional/optional.hpp>
+#include <boost/url/url_view.hpp>
#include <bit>
#include <chrono>
@@ -831,7 +832,13 @@
void doWrite()
{
BMCWEB_LOG_DEBUG("{} doWrite", logPtr(this));
- res.preparePayload();
+
+ boost::urls::url_view urlView;
+ if (req != nullptr)
+ {
+ urlView = req->url();
+ }
+ res.preparePayload(urlView);
startDeadline();
if (httpType == HttpType::HTTP)