public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH] RedfishPkg/RedfishRestExDxe: return HTTP status code to caller.
@ 2023-07-22  8:18 Nickle Wang via groups.io
  2023-07-22 12:09 ` Mike Maslenkin
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Nickle Wang via groups.io @ 2023-07-22  8:18 UTC (permalink / raw)
  To: devel; +Cc: Abner Chang, Igor Kulchytskyy, Nick Ramirez

Return unsupported HTTP status code to caller so caller can handle
HTTP error status code. Current implementation only return EFI error
to caller. Without knowing the HTTP status code, caller has trouble
to handle HTTP request failure.

Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
---
 .../RedfishRestExDxe/RedfishRestExProtocol.c    | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c b/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c
index 90973619f2bc..f11cee8542fb 100644
--- a/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c
+++ b/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c
@@ -320,6 +320,18 @@ ReSendRequest:;
     DEBUG ((DEBUG_ERROR, "This HTTP Status is not handled!\n"));
     DumpHttpStatusCode (DEBUG_REDFISH_NETWORK, ResponseData->Response.StatusCode);
     Status = EFI_UNSUPPORTED;
+
+    //
+    // Deliver status code back to caller so caller can handle it.
+    //
+    ResponseMessage->Data.Response = AllocateZeroPool (sizeof (EFI_HTTP_RESPONSE_DATA));
+    if (ResponseMessage->Data.Response == NULL) {
+      Status = EFI_OUT_OF_RESOURCES;
+      goto ON_EXIT;
+    }
+
+    ResponseMessage->Data.Response->StatusCode = ResponseData->Response.StatusCode;
+
     goto ON_EXIT;
   }
 
@@ -444,11 +456,6 @@ ON_EXIT:
   }
 
   if (EFI_ERROR (Status)) {
-    if (ResponseMessage->Data.Response != NULL) {
-      FreePool (ResponseMessage->Data.Response);
-      ResponseMessage->Data.Response = NULL;
-    }
-
     if (ResponseMessage->Body != NULL) {
       FreePool (ResponseMessage->Body);
       ResponseMessage->Body = NULL;
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107141): https://edk2.groups.io/g/devel/message/107141
Mute This Topic: https://groups.io/mt/100292372/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-09-19 14:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-22  8:18 [edk2-devel] [PATCH] RedfishPkg/RedfishRestExDxe: return HTTP status code to caller Nickle Wang via groups.io
2023-07-22 12:09 ` Mike Maslenkin
2023-08-03  6:06   ` Nickle Wang via groups.io
2023-08-03 10:16     ` Mike Maslenkin
2023-09-18 13:15       ` Nickle Wang via groups.io
2023-09-19 13:53         ` Mike Maslenkin
2023-09-19 14:05           ` Nickle Wang via groups.io
2023-07-24  2:05 ` Chang, Abner via groups.io
2023-07-24  2:06 ` Igor Kulchytskyy via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox