Fix 204/304 incorrectly tracing CRITICAL message
Resolve tracing of CRITICAL message on 1xx, 204(no-content) and 304(not
modified) when there is no body in the response.
The code is changed to check that 1xx, 204 and 304 response with
payloadsize of 0 will not trace the CRITICAL message.
Removed setting of no_content on PATCH that was being done before other
functions are called.
Tested: Used the following commands to check that the CRITICAL message
is no longer being traced for no-content and not modified response with
no body.
204 no-content
```
curl -k -H "Content-Type: application/json" \
-d '{"PowerRestorePolicy":"LastState"}' \
-X PATCH https://${bmc_ip}/redfish/v1/Systems/system
```
```
curl -k -H "Content-Type: application/json" \
-H "X-Auth-Token: $bmc_token" -X PATCH \
-d '{"LocationIndicatorActive":true}' \
https://${bmc_ip}/redfish/v1/Managers/bmc
```
304 not modified
```
curl -k -i https://${bmc_ip}/redfish/ --etag-save etag.out \
-H 'If-Modified-Since: Tue, 21 Nov 2050 08:00:00 GMT'
HTTP/1.1 200 OK
Allow: GET
.
.
.
ETag: "B3A9EAA1"
Content-Type: application/json
Date: Thu, 14 Aug 2025 22:07:27 GMT
Content-Length: 26
ETAG=`cat etag.out`; echo $ETAG
curl -k -i https://${bmc_ip}/redfish/ -H "If-None-Match: ${ETAG}"
HTTP/1.1 304 Not Modified
Allow: GET
.
.
.
ETag: "B3A9EAA1"
Date: Thu, 14 Aug 2025 22:16:27 GMT
Content-Length: 0
```
Change-Id: I98cc096c1f7e506687d4a6bf5a2e51b2231c0d68
Signed-off-by: Abiola Asojo <abiola.asojo@ibm.com>
diff --git a/http/http_response.hpp b/http/http_response.hpp
index 706bfb1..33f24b3 100644
--- a/http/http_response.hpp
+++ b/http/http_response.hpp
@@ -203,8 +203,8 @@
}
response.content_length(*pSize);
- if (is1XXReturn || result() == status::no_content ||
- result() == status::not_modified)
+ if ((*pSize > 0) && (is1XXReturn || result() == status::no_content ||
+ result() == status::not_modified))
{
BMCWEB_LOG_CRITICAL("{} Response content provided but code was "
"no-content or not_modified, which aren't "