RedfishPkg/RedfishRestExDxe: return HTTP status code to caller.

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>
Cc: Mike Maslenkin <mike.maslenkin@gmail.com>
Reviewed-by: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Abner Chang <abner.chang@amd.com>
Acked-by: Mike Maslenkin <mike.maslenkin@gmail.com>
This commit is contained in:
Nickle Wang 2023-07-21 21:35:51 +08:00 committed by mergify[bot]
parent cbcf0428e8
commit 7275993dc6
2 changed files with 16 additions and 14 deletions

View File

@ -131,7 +131,8 @@ typedef struct {
response when the data is retrieved from the service. RequestMessage contains the HTTP
request to the REST resource identified by RequestMessage.Request.Url. The
ResponseMessage is the returned HTTP response for that request, including any HTTP
status.
status. It's caller's responsibility to free this ResponseMessage using FreePool().
RestConfigFreeHttpMessage() in RedfishLib is an example to release ResponseMessage structure.
@param[in] This Pointer to EFI_REST_EX_PROTOCOL instance for a particular
REST service.

View File

@ -29,7 +29,8 @@ EFI_REST_EX_PROTOCOL mRedfishRestExProtocol = {
response when the data is retrieved from the service. RequestMessage contains the HTTP
request to the REST resource identified by RequestMessage.Request.Url. The
ResponseMessage is the returned HTTP response for that request, including any HTTP
status.
status. It's caller's responsibility to free this ResponseMessage using FreePool().
RestConfigFreeHttpMessage() in RedfishLib is an example to release ResponseMessage structure.
@param[in] This Pointer to EFI_REST_EX_PROTOCOL instance for a particular
REST service.
@ -320,6 +321,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;
}
@ -443,18 +456,6 @@ ON_EXIT:
FreePool (ResponseData);
}
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;
}
}
return Status;
}