[edk2-devel] [PATCH v2] RedfishPkg/RedfishRestExDxe: return HTTP status code to caller.

Nickle Wang via groups.io nicklew=nvidia.com at groups.io
Mon Sep 18 13:17:14 UTC 2023


Hi @Abner Chang<mailto:abner.chang at amd.com>



I update the function header of RedfishRestExSendReceive() in 2nd version and I assume there is no need to update UEFI specification for this. Please feel free to correct me if I am wrong.



Thanks,

Nickle



> -----Original Message-----

> From: devel at edk2.groups.io <devel at edk2.groups.io> On Behalf Of Nickle Wang

> via groups.io

> Sent: Monday, September 18, 2023 9:13 PM

> To: devel at edk2.groups.io

> Cc: Abner Chang <abner.chang at amd.com>; Igor Kulchytskyy <igork at ami.com>;

> Nick Ramirez <nramirez at nvidia.com>; Mike Maslenkin

> <mike.maslenkin at gmail.com>

> Subject: [edk2-devel] [PATCH v2] RedfishPkg/RedfishRestExDxe: return HTTP

> status code to caller.

>

> External email: Use caution opening links or attachments

>

>

> 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 at nvidia.com<mailto:nicklew at nvidia.com>>

> Cc: Abner Chang <abner.chang at amd.com<mailto:abner.chang at amd.com>>

> Cc: Igor Kulchytskyy <igork at ami.com<mailto:igork at ami.com>>

> Cc: Nick Ramirez <nramirez at nvidia.com<mailto:nramirez at nvidia.com>>

> Cc: Mike Maslenkin <mike.maslenkin at gmail.com<mailto:mike.maslenkin at gmail.com>>

> ---

>  MdePkg/Include/Protocol/RestEx.h              |  3 ++-

>  .../RedfishRestExDxe/RedfishRestExProtocol.c  | 27 ++++++++++---------

>  2 files changed, 16 insertions(+), 14 deletions(-)

>

> diff --git a/MdePkg/Include/Protocol/RestEx.h

> b/MdePkg/Include/Protocol/RestEx.h

> index e9bc7be94f2c..da9f1c3f87ef 100644

> --- a/MdePkg/Include/Protocol/RestEx.h

> +++ b/MdePkg/Include/Protocol/RestEx.h

> @@ -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.

> diff --git a/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c

> b/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c

> index 90973619f2bc..5bcdade4b18c 100644

> --- a/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c

> +++ b/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c

> @@ -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;

>  }

>

> --

> 2.17.1

>

>

>

> 

>




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108780): https://edk2.groups.io/g/devel/message/108780
Mute This Topic: https://groups.io/mt/101432753/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20230918/94fbb968/attachment-0001.htm>


More information about the edk2-devel-archive mailing list