* [edk2-devel] [PATCH v2] RedfishPkg/RedfishRestExDxe: return HTTP status code to caller.
@ 2023-09-18 13:13 Nickle Wang via groups.io
2023-09-18 13:42 ` Igor Kulchytskyy via groups.io
2023-09-18 15:41 ` Chang, Abner via groups.io
0 siblings, 2 replies; 4+ messages in thread
From: Nickle Wang via groups.io @ 2023-09-18 13:13 UTC (permalink / raw)
To: devel; +Cc: Abner Chang, Igor Kulchytskyy, Nick Ramirez, Mike Maslenkin
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>
---
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 (#108778): https://edk2.groups.io/g/devel/message/108778
Mute This Topic: https://groups.io/mt/101432753/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] 4+ messages in thread
* Re: [edk2-devel] [PATCH v2] RedfishPkg/RedfishRestExDxe: return HTTP status code to caller.
2023-09-18 13:13 [edk2-devel] [PATCH v2] RedfishPkg/RedfishRestExDxe: return HTTP status code to caller Nickle Wang via groups.io
@ 2023-09-18 13:42 ` Igor Kulchytskyy via groups.io
2023-09-18 15:41 ` Chang, Abner via groups.io
1 sibling, 0 replies; 4+ messages in thread
From: Igor Kulchytskyy via groups.io @ 2023-09-18 13:42 UTC (permalink / raw)
To: Nickle Wang, devel@edk2.groups.io
Cc: Abner Chang, Nick Ramirez, Mike Maslenkin
Reviewed-by: Igor Kulchytskyy <igork@ami.com>
Regards,
Igor
-----Original Message-----
From: Nickle Wang <nicklew@nvidia.com>
Sent: Monday, September 18, 2023 9:13 AM
To: devel@edk2.groups.io
Cc: Abner Chang <abner.chang@amd.com>; Igor Kulchytskyy <igork@ami.com>; Nick Ramirez <nramirez@nvidia.com>; Mike Maslenkin <mike.maslenkin@gmail.com>
Subject: [EXTERNAL] [PATCH v2] RedfishPkg/RedfishRestExDxe: return HTTP status code to caller.
**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**
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>
---
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
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108782): https://edk2.groups.io/g/devel/message/108782
Mute This Topic: https://groups.io/mt/101432753/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] 4+ messages in thread
* Re: [edk2-devel] [PATCH v2] RedfishPkg/RedfishRestExDxe: return HTTP status code to caller.
2023-09-18 13:13 [edk2-devel] [PATCH v2] RedfishPkg/RedfishRestExDxe: return HTTP status code to caller Nickle Wang via groups.io
2023-09-18 13:42 ` Igor Kulchytskyy via groups.io
@ 2023-09-18 15:41 ` Chang, Abner via groups.io
1 sibling, 0 replies; 4+ messages in thread
From: Chang, Abner via groups.io @ 2023-09-18 15:41 UTC (permalink / raw)
To: Nickle Wang, devel@edk2.groups.io
Cc: Igor Kulchytskyy, Nick Ramirez, Mike Maslenkin
[AMD Official Use Only - General]
Reviewed-by: Abner Chang <abner.chang@amd.com>
> -----Original Message-----
> From: Nickle Wang <nicklew@nvidia.com>
> Sent: Monday, September 18, 2023 9:13 PM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
> <igork@ami.com>; Nick Ramirez <nramirez@nvidia.com>; Mike Maslenkin
> <mike.maslenkin@gmail.com>
> Subject: [PATCH v2] RedfishPkg/RedfishRestExDxe: return HTTP status code to
> caller.
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> 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>
> ---
> 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 (#108798): https://edk2.groups.io/g/devel/message/108798
Mute This Topic: https://groups.io/mt/101432753/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <1786007649F51CE2.9824@groups.io>]
* Re: [edk2-devel] [PATCH v2] RedfishPkg/RedfishRestExDxe: return HTTP status code to caller.
[not found] <1786007649F51CE2.9824@groups.io>
@ 2023-09-18 13:17 ` Nickle Wang via groups.io
0 siblings, 0 replies; 4+ messages in thread
From: Nickle Wang via groups.io @ 2023-09-18 13:17 UTC (permalink / raw)
To: devel@edk2.groups.io, Nickle Wang, Abner Chang
Cc: Igor Kulchytskyy, Nick Ramirez, Mike Maslenkin
[-- Attachment #1: Type: text/plain, Size: 5266 bytes --]
Hi @Abner Chang<mailto:abner.chang@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@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Nickle Wang
> via groups.io
> Sent: Monday, September 18, 2023 9:13 PM
> To: devel@edk2.groups.io
> Cc: Abner Chang <abner.chang@amd.com>; Igor Kulchytskyy <igork@ami.com>;
> Nick Ramirez <nramirez@nvidia.com>; Mike Maslenkin
> <mike.maslenkin@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@nvidia.com<mailto:nicklew@nvidia.com>>
> Cc: Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>
> Cc: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
> Cc: Nick Ramirez <nramirez@nvidia.com<mailto:nramirez@nvidia.com>>
> Cc: Mike Maslenkin <mike.maslenkin@gmail.com<mailto:mike.maslenkin@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/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 12884 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-09-18 15:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-18 13:13 [edk2-devel] [PATCH v2] RedfishPkg/RedfishRestExDxe: return HTTP status code to caller Nickle Wang via groups.io
2023-09-18 13:42 ` Igor Kulchytskyy via groups.io
2023-09-18 15:41 ` Chang, Abner via groups.io
[not found] <1786007649F51CE2.9824@groups.io>
2023-09-18 13:17 ` Nickle Wang 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