From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 8FAB9D8066D for ; Wed, 1 Nov 2023 04:00:16 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=jzQap6HnWLfwKek7f2tNNShgvu4Te3xd62m84x31Kiw=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:msip_labels:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1698811215; v=1; b=D3OtIWjUn3Ec4bSB+DflXDHbbMHc+j8KKxXO/od2eUzwR1lYeHNwHMG8+oi4RAenja5rR1sa XZrFdbVRE6FXf6l6s7NJMcwcz3lH42arZfDhu3IYZw+wBMu1HO8K6d6CM3YKUC2KU993/HbzPfz Y6hzVN3wwkCS2qWh4VEQbYFQ= X-Received: by 127.0.0.2 with SMTP id BU7pYY7687511xOYF3dZ679t; Tue, 31 Oct 2023 21:00:15 -0700 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.89]) by mx.groups.io with SMTP id smtpd.web11.21.1698811214152933835 for ; Tue, 31 Oct 2023 21:00:14 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lIOpr7ibk9ii1lIiKUNIm90rGBgJDr75/VPxacwaAvoATGiYchSjRKoTCdrD7cXKMPoxRhWOuaprhFxmOadAzv70AJ9n+WCwFy0TNYx3H8xFO3YC8wPAzDP2lUqEVzPTSKK8YR/vaawnY/VthafWa+aGvtLSkHrd76WUkF8LoMfRaypHmLt7J1DArnPDdg6CJ2DhdrvQjOr27l7lTtExlHf2UV6BO+Q1zQLHj8JnSCvsUtQ2R1+L4uuPvV/7340rjXqN7c/tCS7n97Bzo3R2rxgmqiPt1w0t7Vtvu2ftYqHMIF7lWuwrb+8traWx10On5Acb0aaRI9BtmrvPhf93FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=M6TDnTypyQPy4oPrZVtt8Q9K8lbSvcpjCWf444SVCAE=; b=PNq/qAjrWS1QnmN5q9xrw86jQTVyqAVrI1A+7kvqAPQsoXmG26WKz5UImb5et8gaakorNtj93vgUZtd0jR1+8+OAvnFQrO95nvSE/r3HV6LxGebAucTh1D+fnNl7OabzV4pisZKICTNmi2cHKVW/4aX4fBEXO4OVaai+8miaX8AMD6nz93tZs2RoSVTb8f5pQfCWrbrWgv5p+/tANQlwsGPtxk0rSQnQw2mW5Sq2G3hoqkAxWLmZUCzEyypdQpCWgaxtuAWuYCOvhHZTHIT8/EEap6d13J6lb308pDPQ8SN6pgrJs/o36CK3rreuSOQvC3JZx7irQQX/31CiFn0Cfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none X-Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by DS0PR12MB8416.namprd12.prod.outlook.com (2603:10b6:8:ff::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19; Wed, 1 Nov 2023 04:00:06 +0000 X-Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::e670:e45f:fa32:2420]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::e670:e45f:fa32:2420%6]) with mapi id 15.20.6933.029; Wed, 1 Nov 2023 04:00:06 +0000 From: "Chang, Abner via groups.io" To: Nickle Wang , "devel@edk2.groups.io" CC: Igor Kulchytskyy , Nick Ramirez Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH] RedfishClientPkg/RedfishLib: align with edk2 RedfishLib Thread-Topic: [edk2-redfish-client][PATCH] RedfishClientPkg/RedfishLib: align with edk2 RedfishLib Thread-Index: AQHaB+ddYOGZ7cw6b06n17hYQSKeuLBk3+rQ Date: Wed, 1 Nov 2023 04:00:05 +0000 Message-ID: References: <20231026083503.20169-1-nicklew@nvidia.com> In-Reply-To: <20231026083503.20169-1-nicklew@nvidia.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=5cd38332-a5a8-4bd3-88cf-9c3643092816;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-11-01T03:59:49Z;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB3966:EE_|DS0PR12MB8416:EE_ x-ms-office365-filtering-correlation-id: 078526d3-8e5a-4f98-d213-08dbda8f0820 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 0GSG1Jj8ig7JD1uteWYhmu+qGW7JI6/wBGGxEAyzpjtPHh0IuExjB+t6JIam8zRH9cDjYVJhcWaFsPivO5mRaRcNZ7UIQ3p5ymCsPxy+GJlNj4I2XIU0q7fakDe1PurXTjUiTXAm6+/ImzTFYZWc2Hsr0rRxj9SU7eCIxv0/kT42/Ic6umwtNBX3iVCowgBscGsD339/YbmUP9rCkdTb+txp6P+24qJVoFE3ptac+hlh3v/e++j9tqSIrGh5JfNuVKkWQ5hWSX+d4jXxc3deBqcnOiLPELgpd+j82ZSP8JuBzqfFksllp/s5AyHCyKs6kGPg1JCK73x2lIw4jI8qsdfspRQgpkrhAPSBP2ftFwiBA/NxtEDGhjbsN2Lb1YUWg2F/LMwRhItIRQvUL0vFe+kuNHnHNLyzV1KWpshReabvvt6DwML/8FyhwlocyJemtMRMdeNYGbzxOi3xx6B/u/HasGFVqFJ2T64JhNYV5qatUg9UVpeDjXD3UFEWVivhqhEZe3IdCmi0IHigdz2hQMNUGzQAhCr1hteO0U59gB4MY6MuXsYI08TtvcJNNT1bOu4w6eJLeKFyE28itqPeGBdj2ZWY60NaSxxX+K4EcX1Ja1LcuMECr6Sd/1EaDgNjAVc2JnnXqn26UY6WqA4GXi8ygTzU/lQUk15CW69urXY= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?gHo2VbYRS0oX85IEyV7LoPM9xyV/MMAcAClDwQ1TyyMZxCnE7xY9uEZX6TNY?= =?us-ascii?Q?42D1LqqePmnPTXduzjATxAfyn3d64siuH7uxxTMyHnghpv7zx5HZmrAprKUi?= =?us-ascii?Q?gS8tVmNW26VcxHLck8xQF4ThgxFeAq1PuX6Xqu55+nuLYCjU0xX8iSpwC/67?= =?us-ascii?Q?X4ob8LyNoQQLokKASTVq7in+2ifr5iIkU4OApvlYmQw4i4L04D+QumgEssVN?= =?us-ascii?Q?QkbtIFCv9fngPx8g9Vqerl6WxX1EWR3RuRPIYUwh5TmKMIHmrUBG2mCe5Ps/?= =?us-ascii?Q?uLHu4v6ud8r1McxNlaJcUChjBstgqmme4KubqJLcZ1biGQi4SQ2i/rlQpdHM?= =?us-ascii?Q?+HjXVm/y/KLjm2BVO+9JnGYRRFxFSG/lievUQppjFsOTGqkkIU7bPfsa1qOV?= =?us-ascii?Q?OTwLobmMCmnSb+Oo7vCuL98k+dqIV3mXT1r+rH6BgXDOuE7awo7c88hOhe9H?= =?us-ascii?Q?VHMjlQdEm7F/bHR1Nn0334eoHMzuCVYSEzVYdINfQoYGXgBFw+RvqNup6hXE?= =?us-ascii?Q?74w7cL6BIHjuI2L/bryuvkA/5LqY6LzFPz3dCqreJJa+BztwMrHMXrtHzyX0?= =?us-ascii?Q?f0BF1DpRSj5/3tUX1Bxl/nihp3ijZ09W5uyB3jl6o8SZ1YIAXbLsXFEgPXaI?= =?us-ascii?Q?EEUHAZwztYqp6OukiWgCb+fFBjYFzvfAg0G5BisR5K2JD26nbSMr9gnpYke8?= =?us-ascii?Q?fQQnWQ3yLagtSl38Uddns2BRYR4/5HJwQG0w9PNJ12X181DWmBtoJYyd3Czj?= =?us-ascii?Q?yQAoirVGoTnguY7KWPYNv3n6cEPw6Z5i1PY1vAbGum9q/y/qNjZSrQdLZiIb?= =?us-ascii?Q?1bzjNW7YdgWnB5a/ptrLsyva5BKKwZLWtK515oW+8qiulr8i/+SC+7h/Wkno?= =?us-ascii?Q?UkxZJg1Kutui+LZ31vD1UnFt2/8DqtRpThXPWkkOMKjOB9eEqPXwzK36Ekrc?= =?us-ascii?Q?KDK2ONqfXMAP9Fx4IrUxKRsefXZcuGheDV1+P/qc/O/T2DVoZ6SOEgPDTOqH?= =?us-ascii?Q?EvUbvLrlmO6Y3YCRlXDtZio6bco6ZVxYE5S4MM0e9gZVsBOuitdjus767PVt?= =?us-ascii?Q?amERU+bABEJHgUxpnGl3GMHESvnpsKGw86A2pt6Ti1Hq8EgvLKq0uMh6OnoF?= =?us-ascii?Q?JlzK9i+CZB6JDqfkL4X47Dp5CH59/N0P50uXzdp0uEk55Rl8Q427GOQeWg4U?= =?us-ascii?Q?x4hjkYktWEp1SVP3K2nAVew3bHTqFFZostgfGjVQKQH8U6BamQJo9OHdzV0R?= =?us-ascii?Q?DkgjIvc4ZBcWXWENNbV6Ok8NFzq4/XKsjhoRFMXNp/tQqWY816NWzsp6ALzX?= =?us-ascii?Q?lJaubByPmX6ItYkzSDr7IDubHyBuNqyUGi9u8L8gLgE4DUN1tI8CrLI7IRCj?= =?us-ascii?Q?+lY4QUMtZXrnWzIq3nicUU1nJuD0S9XazfpcmbMfYWq95g/YNB5GWnHrlLxL?= =?us-ascii?Q?syJEZejxgsiT2DMpnXuQkCFkMRUlwXEluWeXnBp64F2mpfkrXp9jyWM78BnQ?= =?us-ascii?Q?rxZs0EY40yKBy24Wx1CSdnhOaaYUYvs+GT59oxPIfiLLnXp32QPpaPpZOW/E?= =?us-ascii?Q?CUYtm8uF0lt8b9wYY/OtijxA0WIw5ThD8my+1DEw?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 078526d3-8e5a-4f98-d213-08dbda8f0820 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2023 04:00:05.4509 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: g0GvtJC18wS2GZX1kryLTqSHEGqXVp9INOJ/vwaQWCJ7hTa3OJjjIXeqnZeKv53qoZ6iC94jSEFtQJLYRvRNuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8416 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: M8FQthj46O61lHAd99SeFCq1x7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=D3OtIWjU; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") [AMD Official Use Only - General] Reviewed-by: Abner Chang > -----Original Message----- > From: Nickle Wang > Sent: Thursday, October 26, 2023 4:35 PM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Igor Kulchytskyy > ; Nick Ramirez > Subject: [edk2-redfish-client][PATCH] RedfishClientPkg/RedfishLib: align = with > edk2 RedfishLib > > Caution: This message originated from an External Source. Use proper caut= ion > when opening attachments, clicking links, or responding. > > > Update RedfishLib to align with RedfishLib in edk2 repository. > RedfishLib commits on edk2: > cf68ff61 RedfishPkg/RedfishLib: introduce new interfaces. > 1cbdd6e9 RedfishPkg/libredfish: introduce new interfaces. > 8765f3eb RedfishPkg/RedfishLib: return HTTP headers to caller. > > Signed-off-by: Nickle Wang > Cc: Abner Chang > Cc: Igor Kulchytskyy > Cc: Nick Ramirez > --- > .../PrivateLibrary/RedfishLib/RedfishLib.inf | 1 + > .../edk2libredfish/include/redfishPayload.h | 32 +- > .../edk2libredfish/include/redfishService.h | 21 + > .../PrivateLibrary/RedfishLib/RedfishLib.c | 345 +++++++++++- > .../PrivateLibrary/RedfishLib/RedfishMisc.c | 13 +- > .../RedfishLib/edk2libredfish/src/payload.c | 124 +--- > .../RedfishLib/edk2libredfish/src/service.c | 531 ++++++------------ > 7 files changed, 527 insertions(+), 540 deletions(-) > > diff --git a/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.inf > b/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.inf > index a54e397d..79d8792f 100644 > --- a/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.inf > +++ b/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.inf > @@ -3,6 +3,7 @@ > # > # Copyright (c) 2019, Intel Corporation. All rights reserved.
> # (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > # > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > diff --git > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= shP > ayload.h > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= shP > ayload.h > index 8403d693..f7917603 100644 > --- > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= shP > ayload.h > +++ > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= shP > ayload.h > @@ -10,6 +10,7 @@ > > Copyright (c) 2019, Intel Corporation. All rights reserved.
> (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -19,7 +20,7 @@ > #define LIBREDFISH_REDFISH_PAYLOAD_H_ > > #include > - > +#include > #include > #include > #include > @@ -65,15 +66,6 @@ patchPayload ( > EFI_HTTP_STATUS_CODE **StatusCode > ); > > -redfishPayload * > -patchPayloadEx ( > - redfishPayload *target, > - redfishPayload *payload, > - EFI_HTTP_HEADER **Headers, > - UINTN *HeaderCount, > - EFI_HTTP_STATUS_CODE **StatusCode > - ); > - > redfishPayload * > postContentToPayload ( > redfishPayload *target, > @@ -83,17 +75,6 @@ postContentToPayload ( > EFI_HTTP_STATUS_CODE **StatusCode > ); > > -redfishPayload * > -postContentToPayloadEx ( > - redfishPayload *target, > - const char *data, > - size_t dataSize, > - const char *contentType, > - EFI_HTTP_HEADER **Headers, > - UINTN *HeaderCount, > - EFI_HTTP_STATUS_CODE **StatusCode > - ); > - > redfishPayload * > postPayload ( > redfishPayload *target, > @@ -101,15 +82,6 @@ postPayload ( > EFI_HTTP_STATUS_CODE **StatusCode > ); > > -redfishPayload * > -postPayloadEx ( > - redfishPayload *target, > - redfishPayload *payload, > - EFI_HTTP_HEADER **Headers, > - UINTN *HeaderCount, > - EFI_HTTP_STATUS_CODE **StatusCode > - ); > - > void > cleanupPayload ( > redfishPayload *payload > diff --git > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= shS > ervice.h > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= shS > ervice.h > index c41c0d14..c2e0fd32 100644 > --- > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= shS > ervice.h > +++ > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= shS > ervice.h > @@ -10,6 +10,7 @@ > > Copyright (c) 2019, Intel Corporation. All rights reserved.
> (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -153,6 +154,18 @@ postUriFromServiceEx ( > EFI_HTTP_STATUS_CODE **StatusCode > ); > > +json_t * > +putUriFromServiceEx ( > + redfishService *service, > + const char *uri, > + const char *content, > + size_t contentLength, > + const char *contentType, > + EFI_HTTP_HEADER **Headers, > + UINTN *HeaderCount, > + EFI_HTTP_STATUS_CODE **StatusCode > + ); > + > json_t * > deleteUriFromService ( > redfishService *service, > @@ -160,6 +173,14 @@ deleteUriFromService ( > EFI_HTTP_STATUS_CODE **StatusCode > ); > > +json_t * > +deleteUriFromServiceEx ( > + redfishService *service, > + const char *uri, > + const char *content, > + EFI_HTTP_STATUS_CODE **StatusCode > + ); > + > redfishPayload * > getRedfishServiceRoot ( > redfishService *service, > diff --git a/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.c > b/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.c > index c00b15f6..8a4483b4 100644 > --- a/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.c > +++ b/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.c > @@ -4,6 +4,7 @@ > > Copyright (c) 2019, Intel Corporation. All rights reserved.
> (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -167,6 +168,30 @@ RedfishJsonInPayload ( > return ((redfishPayload *)Payload)->json; > } > > +/** > + This function returns the Redfish service of a REDFISH_PAYLOAD. > + > + Caller doesn't need to free the returned JSON value because it will be > released > + in corresponding RedfishCleanupService() function. > + > + @param[in] Payload A REDFISH_PAYLOAD instance. > + > + @return Redfish service of the payload. > + > +**/ > +REDFISH_SERVICE > +EFIAPI > +RedfishServiceInPayload ( > + IN REDFISH_PAYLOAD Payload > + ) > +{ > + if (Payload =3D=3D NULL) { > + return NULL; > + } > + > + return ((redfishPayload *)Payload)->service; > +} > + > /** > Fill the input RedPath string with system UUID from SMBIOS table or us= e the > customized > ID if FromSmbios =3D=3D FALSE. > @@ -244,7 +269,7 @@ RedfishBuildPathWithSystemUuid ( > from the root node. > @param[out] RedResponse Pointer to the Redfish response da= ta. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation is successful, indicates= the HTTP > StatusCode is not > NULL and the value is 2XX. The corresp= onding redfish > resource has > been returned in Payload within RedRes= ponse. > @retval EFI_INVALID_PARAMETER RedfishService, RedPath, or > RedResponse is NULL. > @@ -304,7 +329,7 @@ RedfishGetByService ( > @param[in] Uri String to address a resource. > @param[out] RedResponse Pointer to the Redfish response data. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation is successful, indicates= the HTTP > StatusCode is not > NULL and the value is 2XX. The corresp= onding redfish > resource has > been returned in Payload within RedRes= ponse. > @retval EFI_INVALID_PARAMETER RedfishService, RedPath, or > RedResponse is NULL. > @@ -367,7 +392,7 @@ RedfishGetByUri ( > @param[in] RedPath Relative RedPath string to address a r= esource > inside Payload. > @param[out] RedResponse Pointer to the Redfish response data. > > - @retval EFI_SUCCESS The opeartion is successful: > + @retval EFI_SUCCESS The operation is successful: > 1. The HTTP StatusCode is NULL and the= returned Payload in > RedResponse is not NULL, indicates the= Redfish resource has > been parsed from the input payload dir= ectly. > @@ -440,7 +465,7 @@ RedfishGetByPayload ( > @param[in] Content JSON represented properties to be = update. > @param[out] RedResponse Pointer to the Redfish response da= ta. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation is successful, indicates= the HTTP > StatusCode is not > NULL and the value is 2XX. The Redfish= resource will be > returned > in Payload within RedResponse if serve= r send it back in the > HTTP > response message body. > @@ -473,10 +498,12 @@ RedfishPatchToUri ( > > ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); > > - JsonValue =3D (EDKII_JSON_VALUE)patchUriFromService ( > + JsonValue =3D (EDKII_JSON_VALUE)patchUriFromServiceEx ( > RedfishService, > Uri, > Content, > + &(RedResponse->Headers), > + &(RedResponse->HeaderCount), > &(RedResponse->StatusCode) > ); > > @@ -527,10 +554,10 @@ ON_EXIT: > redfish response data. > > @param[in] Target The target payload to be updated. > - @param[in] Payload Palyoad with properties to be changed. > + @param[in] Payload Payload with properties to be changed. > @param[out] RedResponse Pointer to the Redfish response data. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation is successful, indicates= the HTTP > StatusCode is not > NULL and the value is 2XX. The Redfish= resource will be > returned > in Payload within RedResponse if serve= r send it back in the > HTTP > response message body. > @@ -556,11 +583,9 @@ RedfishPatchToPayload ( > > ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); > > - RedResponse->Payload =3D (REDFISH_PAYLOAD)patchPayloadEx ( > + RedResponse->Payload =3D (REDFISH_PAYLOAD)patchPayload ( > Target, > Payload, > - &RedResponse->Headers, > - &RedResponse->HeaderCount, > &(RedResponse->StatusCode) > ); > > @@ -585,6 +610,104 @@ RedfishPatchToPayload ( > return EFI_SUCCESS; > } > > +/** > + Use HTTP POST to create new Redfish resource in the Resource Collectio= n. > + > + The POST request should be submitted to the Resource Collection in whi= ch > the new resource > + is to belong. The Resource Collection is addressed by URI. The Redfish= may > + ignore any service controlled properties. The corresponding redfish > response will returned, > + including HTTP StatusCode, Headers and Payload which record any HTTP > response messages. > + > + Callers are responsible for freeing the HTTP StatusCode, Headers and > Payload returned in > + redfish response data. > + > + @param[in] RedfishService The Service to access the Redfish = resources. > + @param[in] Uri Relative path to address the resou= rce. > + @param[in] Content JSON represented properties to be = update. > + @param[in] ContentSize Size of the Content to be send to = Redfish > service > + @param[in] ContentType Type of the Content to be send to = Redfish > service > + @param[out] RedResponse Pointer to the Redfish response da= ta. > + > + @retval EFI_SUCCESS The operation is successful, indicates= the HTTP > StatusCode is not > + NULL and the value is 2XX. The Redfish= resource will be > returned > + in Payload within RedResponse if serve= r send it back in the > HTTP > + response message body. > + @retval EFI_INVALID_PARAMETER RedfishService, Uri, Content, or > RedResponse is NULL. > + @retval EFI_DEVICE_ERROR An unexpected system or network error > occurred. Callers can get > + more error info from returned HTTP Sta= tusCode, Headers > and Payload > + within RedResponse: > + 1. If the returned StatusCode is NULL,= indicates any error > happen. > + 2. If the returned StatusCode is not N= ULL and the value is > not 2XX, > + indicates any error happen. > +**/ > +EFI_STATUS > +EFIAPI > +RedfishPostToUri ( > + IN REDFISH_SERVICE RedfishService, > + IN CONST CHAR8 *Uri, > + IN CONST CHAR8 *Content, > + IN UINTN ContentSize OPTIONAL, > + IN CONST CHAR8 *ContentType OPTIONAL, > + OUT REDFISH_RESPONSE *RedResponse > + ) > +{ > + EFI_STATUS Status; > + EDKII_JSON_VALUE JsonValue; > + > + Status =3D EFI_SUCCESS; > + JsonValue =3D NULL; > + > + if ((RedfishService =3D=3D NULL) || (Uri =3D=3D NULL) || (Content =3D= =3D NULL) || > (RedResponse =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); > + > + JsonValue =3D (EDKII_JSON_VALUE)postUriFromServiceEx ( > + RedfishService, > + Uri, > + Content, > + ContentSize, > + ContentType, > + &(RedResponse->Headers), > + &(RedResponse->HeaderCount), > + &(RedResponse->StatusCode) > + ); > + > + // > + // 1. If the returned StatusCode is NULL, indicates any error happen. > + // > + if (RedResponse->StatusCode =3D=3D NULL) { > + Status =3D EFI_DEVICE_ERROR; > + goto ON_EXIT; > + } > + > + // > + // 2. If the returned StatusCode is not NULL and the value is not 2XX, > indicates any error happen. > + // NOTE: If there is any error message returned from server, it wil= l be > returned in > + // Payload within RedResponse. > + // > + if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \ > + (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)) > + { > + Status =3D EFI_DEVICE_ERROR; > + } > + > +ON_EXIT: > + if (JsonValue !=3D NULL) { > + RedResponse->Payload =3D createRedfishPayload (JsonValue, > RedfishService); > + if (RedResponse->Payload =3D=3D NULL) { > + // > + // Ignore the error when create RedfishPayload, just free the Json= Value > since it's not what > + // we care about if the returned StatusCode is 2XX. > + // > + JsonValueFree (JsonValue); > + } > + } > + > + return Status; > +} > + > /** > Use HTTP POST to create a new resource in target payload. > > @@ -600,7 +723,7 @@ RedfishPatchToPayload ( > @param[in] Payload The new resource to be created. > @param[out] RedResponse Pointer to the Redfish response data. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation is successful, indicates= the HTTP > StatusCode is not > NULL and the value is 2XX. The Redfish= resource will be > returned > in Payload within RedResponse if serve= r send it back in the > HTTP > response message body. > @@ -626,11 +749,9 @@ RedfishPostToPayload ( > > ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); > > - RedResponse->Payload =3D (REDFISH_PAYLOAD)postPayloadEx ( > + RedResponse->Payload =3D (REDFISH_PAYLOAD)postPayload ( > Target, > Payload, > - &RedResponse->Headers, > - &RedResponse->HeaderCount, > &(RedResponse->StatusCode) > ); > > @@ -670,7 +791,7 @@ RedfishPostToPayload ( > @param[in] Uri Relative path to address the resou= rce. > @param[out] RedResponse Pointer to the Redfish response da= ta. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation is successful, indicates= the HTTP > StatusCode is not > NULL and the value is 2XX, the Redfish= resource has been > removed. > If there is any message returned from = server, it will be > returned > in Payload within RedResponse. > @@ -742,6 +863,96 @@ ON_EXIT: > return Status; > } > > +/** > + Use HTTP DELETE to remove a resource. > + > + This function uses the RedfishService to remove a Redfish resource whi= ch is > addressed > + by input Uri (only the relative path is required). The corresponding r= edfish > response will > + returned, including HTTP StatusCode, Headers and Payload which record > any HTTP response > + messages. > + > + Callers are responsible for freeing the HTTP StatusCode, Headers and > Payload returned in > + redfish response data. > + > + @param[in] RedfishService The Service to access the Redfish = resources. > + @param[in] Uri Relative path to address the resou= rce. > + @param[in] Content JSON represented properties to be = deleted. > + @param[out] RedResponse Pointer to the Redfish response da= ta. > + > + @retval EFI_SUCCESS The operation is successful, indicates= the HTTP > StatusCode is not > + NULL and the value is 2XX, the Redfish= resource has been > removed. > + If there is any message returned from = server, it will be > returned > + in Payload within RedResponse. > + @retval EFI_INVALID_PARAMETER RedfishService, Uri, or RedResponse is > NULL. > + @retval EFI_DEVICE_ERROR An unexpected system or network error > occurred. Callers can get > + more error info from returned HTTP Sta= tusCode, Headers > and Payload > + within RedResponse: > + 1. If the returned StatusCode is NULL,= indicates any error > happen. > + 2. If the returned StatusCode is not N= ULL and the value is > not 2XX, > + indicates any error happen. > +**/ > +EFI_STATUS > +EFIAPI > +RedfishDeleteByUriEx ( > + IN REDFISH_SERVICE RedfishService, > + IN CONST CHAR8 *Uri, > + IN CONST CHAR8 *Content, > + OUT REDFISH_RESPONSE *RedResponse > + ) > +{ > + EFI_STATUS Status; > + EDKII_JSON_VALUE JsonValue; > + > + Status =3D EFI_SUCCESS; > + JsonValue =3D NULL; > + > + if ((RedfishService =3D=3D NULL) || (Content =3D=3D NULL) || (Uri =3D= =3D NULL) || > (RedResponse =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); > + > + JsonValue =3D (EDKII_JSON_VALUE)deleteUriFromServiceEx ( > + RedfishService, > + Uri, > + Content, > + &(RedResponse->StatusCode) > + ); > + > + // > + // 1. If the returned StatusCode is NULL, indicates any error happen. > + // > + if (RedResponse->StatusCode =3D=3D NULL) { > + Status =3D EFI_DEVICE_ERROR; > + goto ON_EXIT; > + } > + > + // > + // 2. If the returned StatusCode is not NULL and the value is not 2XX, > indicates any error happen. > + // NOTE: If there is any error message returned from server, it wil= l be > returned in > + // Payload within RedResponse. > + // > + if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \ > + (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)) > + { > + Status =3D EFI_DEVICE_ERROR; > + } > + > +ON_EXIT: > + if (JsonValue !=3D NULL) { > + RedResponse->Payload =3D createRedfishPayload (JsonValue, > RedfishService); > + if (RedResponse->Payload =3D=3D NULL) { > + // > + // Ignore the error when create RedfishPayload, just free the Json= Value > since it's not what > + // we care about if the returned StatusCode is 2XX. > + // > + JsonValueFree (JsonValue); > + } > + } > + > + return Status; > +} > + > /** > Dump text in fractions. > > @@ -878,7 +1089,7 @@ RedfishFreeResponse ( > Check if the "@odata.type" in Payload is valid or not. > > @param[in] Payload The Redfish payload to be checked= . > - @param[in] OdataTypeName OdataType will be retrived from > mapping list. > + @param[in] OdataTypeName OdataType will be retrieved from > mapping list. > @param[in] OdataTypeMappingList The list of OdataType. > @param[in] OdataTypeMappingListSize The number of mapping list > > @@ -945,7 +1156,7 @@ RedfishIsPayloadCollection ( > @param[in] Payload The Redfish collection payload > @param[in] CollectionSize Size of this collection > > - @return EFI_SUCCESS Coolection size is returned in Collec= tionSize > + @return EFI_SUCCESS Collection size is returned in Collec= tionSize > @return EFI_INVALID_PARAMETER The payload is not a collection. > **/ > EFI_STATUS > @@ -1035,3 +1246,103 @@ RedfishCheckIfRedpathExist ( > > return EFI_SUCCESS; > } > + > +/** > + Use HTTP PUT to create new Redfish resource in the Resource Collection= . > + > + This function uses the RedfishService to put a Redfish resource addres= sed by > + Uri (only the relative path is required). Changes to one or more prope= rties > within > + the target resource are represented in the input Content, properties n= ot > specified > + in Content won't be changed by this request. The corresponding redfish > response will > + returned, including HTTP StatusCode, Headers and Payload which record > any HTTP response > + messages. > + > + Callers are responsible for freeing the HTTP StatusCode, Headers and > Payload returned in > + redfish response data. > + > + @param[in] RedfishService The Service to access the Redfish = resources. > + @param[in] Uri Relative path to address the resou= rce. > + @param[in] Content JSON represented properties to be = update. > + @param[in] ContentSize Size of the Content to be send to = Redfish > service > + @param[in] ContentType Type of the Content to be send to = Redfish > service > + @param[out] RedResponse Pointer to the Redfish response da= ta. > + > + @retval EFI_SUCCESS The operation is successful, indicates= the HTTP > StatusCode is not > + NULL and the value is 2XX. The Redfish= resource will be > returned > + in Payload within RedResponse if serve= r send it back in the > HTTP > + response message body. > + @retval EFI_INVALID_PARAMETER RedfishService, Uri, Content, or > RedResponse is NULL. > + @retval EFI_DEVICE_ERROR An unexpected system or network error > occurred. Callers can get > + more error info from returned HTTP Sta= tusCode, Headers > and Payload > + within RedResponse: > + 1. If the returned StatusCode is NULL,= indicates any error > happen. > + 2. If the returned StatusCode is not N= ULL and the value is > not 2XX, > + indicates any error happen. > +**/ > +EFI_STATUS > +EFIAPI > +RedfishPutToUri ( > + IN REDFISH_SERVICE RedfishService, > + IN CONST CHAR8 *Uri, > + IN CONST CHAR8 *Content, > + IN UINTN ContentSize OPTIONAL, > + IN CONST CHAR8 *ContentType OPTIONAL, > + OUT REDFISH_RESPONSE *RedResponse > + ) > +{ > + EFI_STATUS Status; > + EDKII_JSON_VALUE JsonValue; > + > + Status =3D EFI_SUCCESS; > + JsonValue =3D NULL; > + > + if ((RedfishService =3D=3D NULL) || (Uri =3D=3D NULL) || (Content =3D= =3D NULL) || > (RedResponse =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); > + > + JsonValue =3D (EDKII_JSON_VALUE)putUriFromServiceEx ( > + RedfishService, > + Uri, > + Content, > + ContentSize, > + ContentType, > + &(RedResponse->Headers), > + &(RedResponse->HeaderCount), > + &(RedResponse->StatusCode) > + ); > + > + // > + // 1. If the returned StatusCode is NULL, indicates any error happen. > + // > + if (RedResponse->StatusCode =3D=3D NULL) { > + Status =3D EFI_DEVICE_ERROR; > + goto ON_EXIT; > + } > + > + // > + // 2. If the returned StatusCode is not NULL and the value is not 2XX, > indicates any error happen. > + // NOTE: If there is any error message returned from server, it wil= l be > returned in > + // Payload within RedResponse. > + // > + if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \ > + (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)) > + { > + Status =3D EFI_DEVICE_ERROR; > + } > + > +ON_EXIT: > + if (JsonValue !=3D NULL) { > + RedResponse->Payload =3D createRedfishPayload (JsonValue, > RedfishService); > + if (RedResponse->Payload =3D=3D NULL) { > + // > + // Ignore the error when create RedfishPayload, just free the Json= Value > since it's not what > + // we care about if the returned StatusCode is 2XX. > + // > + JsonValueFree (JsonValue); > + } > + } > + > + return Status; > +} > diff --git a/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishMisc.c > b/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishMisc.c > index 0eb23196..b6e9a111 100644 > --- a/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishMisc.c > +++ b/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishMisc.c > @@ -3,6 +3,7 @@ > > Copyright (c) 2019, Intel Corporation. All rights reserved.
> (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -168,18 +169,18 @@ RedfishGetAuthInfo ( > /** > This function returns the string of Redfish service version. > > - @param[in] ServiceVerisonStr The string of Redfish service version. > + @param[in] ServiceVersionStr The string of Redfish service version. > @param[in] Url The URL to build Redpath with ID. > Start with "/", for example "/Registrie= s" > @param[in] Id ID string > - @param[out] Redpath Pointer to retrive Redpath, caller has = to free > + @param[out] Redpath Pointer to retrieved Redpath, caller ha= s to free > the memory allocated for this string. > @return EFI_STATUS > > **/ > EFI_STATUS > RedfishBuildRedpathUseId ( > - IN CHAR8 *ServiceVerisonStr, > + IN CHAR8 *ServiceVersionStr, > IN CHAR8 *Url, > IN CHAR8 *Id, > OUT CHAR8 **Redpath > @@ -187,12 +188,12 @@ RedfishBuildRedpathUseId ( > { > UINTN RedpathSize; > > - if ((Redpath =3D=3D NULL) || (ServiceVerisonStr =3D=3D NULL) || (Url = =3D=3D NULL) || (Id > =3D=3D NULL)) { > + if ((Redpath =3D=3D NULL) || (ServiceVersionStr =3D=3D NULL) || (Url = =3D=3D NULL) || (Id > =3D=3D NULL)) { > return EFI_INVALID_PARAMETER; > } > > RedpathSize =3D AsciiStrLen ("/") + > - AsciiStrLen (ServiceVerisonStr) + > + AsciiStrLen (ServiceVersionStr) + > AsciiStrLen (Url) + > AsciiStrLen ("[Id=3D]") + > AsciiStrLen (Id) + 1; > @@ -201,6 +202,6 @@ RedfishBuildRedpathUseId ( > return EFI_OUT_OF_RESOURCES; > } > > - AsciiSPrint (*Redpath, RedpathSize, "/%a%a[Id=3D%a]", ServiceVerisonSt= r, Url, > Id); > + AsciiSPrint (*Redpath, RedpathSize, "/%a%a[Id=3D%a]", ServiceVersionSt= r, Url, > Id); > return EFI_SUCCESS; > } > diff --git > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c > index 8ec2ed4a..39803575 100644 > --- a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/paylo= ad.c > +++ > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c > @@ -10,6 +10,7 @@ > > Copyright (c) 2019, Intel Corporation. All rights reserved.
> (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -379,45 +380,6 @@ getPayloadForPathString ( > return ret; > } > > -redfishPayload * > -patchPayloadEx ( > - redfishPayload *target, > - redfishPayload *payload, > - EFI_HTTP_HEADER **Headers, > - UINTN *HeaderCount, > - EFI_HTTP_STATUS_CODE **StatusCode > - ) > -{ > - json_t *json; > - char *content; > - char *uri; > - > - if (!target || !payload || (StatusCode =3D=3D NULL)) { > - return NULL; > - } > - > - *StatusCode =3D NULL; > - > - json =3D json_object_get (target->json, "@odata.id"); > - if (json =3D=3D NULL) { > - return NULL; > - } > - > - uri =3D strdup (json_string_value (json)); > - > - content =3D json_dumps (payload->json, 0); > - json_decref (json); > - > - json =3D patchUriFromServiceEx (target->service, uri, content, Headers= , > HeaderCount, StatusCode); > - free (uri); > - free (content); > - if (json =3D=3D NULL) { > - return NULL; > - } > - > - return createRedfishPayload (json, target->service); > -} > - > redfishPayload * > patchPayload ( > redfishPayload *target, > @@ -455,44 +417,6 @@ patchPayload ( > return createRedfishPayload (json, target->service); > } > > -redfishPayload * > -postContentToPayloadEx ( > - redfishPayload *target, > - const char *data, > - size_t dataSize, > - const char *contentType, > - EFI_HTTP_HEADER **Headers, > - UINTN *HeaderCount, > - EFI_HTTP_STATUS_CODE **StatusCode > - ) > -{ > - json_t *json; > - char *uri; > - > - if (!target || !data || (StatusCode =3D=3D NULL)) { > - return NULL; > - } > - > - *StatusCode =3D NULL; > - > - json =3D json_object_get (target->json, "@odata.id"); > - if (json =3D=3D NULL) { > - json =3D json_object_get (target->json, "target"); > - if (json =3D=3D NULL) { > - return NULL; > - } > - } > - > - uri =3D strdup (json_string_value (json)); > - json =3D postUriFromServiceEx (target->service, uri, data, dataSize, > contentType, Headers, HeaderCount, StatusCode); > - free (uri); > - if (json =3D=3D NULL) { > - return NULL; > - } > - > - return createRedfishPayload (json, target->service); > -} > - > redfishPayload * > postContentToPayload ( > redfishPayload *target, > @@ -529,34 +453,6 @@ postContentToPayload ( > return createRedfishPayload (json, target->service); > } > > -redfishPayload * > -postPayloadEx ( > - redfishPayload *target, > - redfishPayload *payload, > - EFI_HTTP_HEADER **Headers, > - UINTN *HeaderCount, > - EFI_HTTP_STATUS_CODE **StatusCode > - ) > -{ > - char *content; > - redfishPayload *ret; > - > - if (!target || !payload || (StatusCode =3D=3D NULL)) { > - return NULL; > - } > - > - *StatusCode =3D NULL; > - > - if (!json_is_object (payload->json)) { > - return NULL; > - } > - > - content =3D payloadToString (payload, false); > - ret =3D postContentToPayloadEx (target, content, strlen (content),= NULL, > Headers, HeaderCount, StatusCode); > - free (content); > - return ret; > -} > - > redfishPayload * > postPayload ( > redfishPayload *target, > @@ -629,7 +525,7 @@ getOpResult ( > } > > stringProp =3D prop->json; > - jsonType =3D json_get_type (prop->json); > + jsonType =3D JsonGetType (prop->json); > switch (jsonType) { > case JSON_OBJECT: > stringProp =3D json_object_get (prop->json, propName); > @@ -725,6 +621,7 @@ collectionEvalOp ( > if (((*StatusCode =3D=3D NULL) && (members =3D=3D NULL)) || > ((*StatusCode !=3D NULL) && ((**StatusCode < HTTP_STATUS_200_OK) |= | > (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT)))) > { > + free (valid); > return members; > } > > @@ -738,6 +635,7 @@ collectionEvalOp ( > if (((*StatusCode =3D=3D NULL) && (tmp =3D=3D NULL)) || > ((*StatusCode !=3D NULL) && ((**StatusCode < HTTP_STATUS_200_OK)= || > (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT)))) > { > + free (valid); > return tmp; > } > > @@ -763,19 +661,15 @@ collectionEvalOp ( > > cleanupPayload (members); > if (validCount =3D=3D 0) { > - free (valid); > - return NULL; > - } > - > - if (validCount =3D=3D 1) { > + ret =3D NULL; > + } else if (validCount =3D=3D 1) { > ret =3D valid[0]; > - free (valid); > - return ret; > } else { > ret =3D createCollection (payload->service, validCount, valid); > - free (valid); > - return ret; > } > + > + free (valid); > + return ret; > } > > static redfishPayload * > diff --git > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c > index a38bdfbe..58c23e8c 100644 > --- a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/servi= ce.c > +++ > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c > @@ -10,6 +10,7 @@ > > Copyright (c) 2019, Intel Corporation. All rights reserved.
> (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -279,9 +280,9 @@ DecodeResponseContent ( > **/ > EFI_STATUS > RedfishBuildUrl ( > - IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo, > - IN CHAR16 *RelativePath, OPTIONAL > - OUT CHAR16 **HttpUrl > + IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo, > + IN CHAR16 *RelativePath OPTIONAL, > + OUT CHAR16 **HttpUrl > ) > { > CHAR16 *Url; > @@ -434,8 +435,8 @@ json_t * > getUriFromServiceEx ( > redfishService *service, > const char *uri, > - EFI_HTTP_HEADER **Headers, > - UINTN *HeaderCount, > + EFI_HTTP_HEADER **Headers OPTIONAL, > + UINTN *HeaderCount OPTIONAL, > EFI_HTTP_STATUS_CODE **StatusCode > ) > { > @@ -448,20 +449,25 @@ getUriFromServiceEx ( > EFI_HTTP_MESSAGE ResponseMsg; > EFI_HTTP_HEADER *ContentEncodedHeader; > > - if ((service =3D=3D NULL) || (uri =3D=3D NULL) || (Headers =3D=3D NULL= ) || (HeaderCount > =3D=3D NULL) || (StatusCode =3D=3D NULL)) { > + if ((service =3D=3D NULL) || (uri =3D=3D NULL) || (StatusCode =3D=3D N= ULL)) { > return NULL; > } > > - *StatusCode =3D NULL; > - *HeaderCount =3D 0; > - *Headers =3D NULL; > + *StatusCode =3D NULL; > + if (HeaderCount !=3D NULL) { > + *HeaderCount =3D 0; > + } > + > + if (Headers !=3D NULL) { > + *Headers =3D NULL; > + } > > url =3D makeUrlForService (service, uri); > if (!url) { > return NULL; > } > > - DEBUG ((DEBUG_MANAGEABILITY, "libredfish: getUriFromServiceEx(): > %a\n", url)); > + DEBUG ((DEBUG_MANAGEABILITY, "%a: %a\n", __func__, url)); > > // > // Step 1: Create HTTP request message with 4 headers: > @@ -524,166 +530,23 @@ getUriFromServiceEx ( > Status =3D service->RestEx->SendReceive (service->RestEx, RequestMsg, > &ResponseMsg); > if (EFI_ERROR (Status)) { > ret =3D NULL; > - goto ON_EXIT; > - } > - > - // > - // Step 5: Return the HTTP StatusCode and Body message. > - // > - if (ResponseMsg.Data.Response !=3D NULL) { > - *StatusCode =3D AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE)); > - if (*StatusCode =3D=3D NULL) { > - ret =3D NULL; > - goto ON_EXIT; > - } > > // > - // The caller shall take the responsibility to free the buffer. > + // Deliver status code to caller when error happens so caller can do= error > handling. > // > - **StatusCode =3D ResponseMsg.Data.Response->StatusCode; > - } > - > - if (ResponseMsg.Headers !=3D NULL) { > - *Headers =3D cloneHttpHeaders (&ResponseMsg, HeaderCount); > - } > - > - if ((ResponseMsg.BodyLength !=3D 0) && (ResponseMsg.Body !=3D NULL)) { > - // > - // Check if data is encoded. > - // > - ContentEncodedHeader =3D HttpFindHeader (ResponseMsg.HeaderCount, > ResponseMsg.Headers, HTTP_HEADER_CONTENT_ENCODING); > - if (ContentEncodedHeader !=3D NULL) { > - // > - // The content is encoded. > - // > - Status =3D DecodeResponseContent (ContentEncodedHeader->FieldValue= , > &ResponseMsg.Body, &ResponseMsg.BodyLength); > - if (EFI_ERROR (Status)) { > - DEBUG ((DEBUG_ERROR, "%a: Failed to decompress the response > content %r\n.", __func__, Status)); > + if (ResponseMsg.Data.Response !=3D NULL) { > + *StatusCode =3D AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE)); > + if (*StatusCode =3D=3D NULL) { > ret =3D NULL; > goto ON_EXIT; > } > - } > - > - ret =3D json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NUL= L); > - } else { > - // > - // There is no message body returned from server. > - // > - ret =3D NULL; > - } > > -ON_EXIT: > - if (url !=3D NULL) { > - free (url); > - } > - > - if (HttpIoHeader !=3D NULL) { > - HttpIoFreeHeader (HttpIoHeader); > - } > - > - if (RequestData !=3D NULL) { > - RestConfigFreeHttpRequestData (RequestData); > - } > - > - if (RequestMsg !=3D NULL) { > - FreePool (RequestMsg); > - } > - > - RestConfigFreeHttpMessage (&ResponseMsg, FALSE); > - > - return ret; > -} > - > -json_t * > -getUriFromService ( > - redfishService *service, > - const char *uri, > - EFI_HTTP_STATUS_CODE **StatusCode > - ) > -{ > - char *url; > - json_t *ret; > - HTTP_IO_HEADER *HttpIoHeader =3D NULL; > - EFI_STATUS Status; > - EFI_HTTP_REQUEST_DATA *RequestData =3D NULL; > - EFI_HTTP_MESSAGE *RequestMsg =3D NULL; > - EFI_HTTP_MESSAGE ResponseMsg; > - EFI_HTTP_HEADER *ContentEncodedHeader; > - > - if ((service =3D=3D NULL) || (uri =3D=3D NULL) || (StatusCode =3D=3D N= ULL)) { > - return NULL; > - } > - > - *StatusCode =3D NULL; > - > - url =3D makeUrlForService (service, uri); > - if (!url) { > - return NULL; > - } > - > - DEBUG ((DEBUG_MANAGEABILITY, "libredfish: getUriFromService(): %a\n", > url)); > - > - // > - // Step 1: Create HTTP request message with 4 headers: > - // > - HttpIoHeader =3D HttpIoCreateHeader ((service->sessionToken || service= - > >basicAuthStr) ? 6 : 5); > - if (HttpIoHeader =3D=3D NULL) { > - ret =3D NULL; > - goto ON_EXIT; > - } > - > - if (service->sessionToken) { > - Status =3D HttpIoSetHeader (HttpIoHeader, "X-Auth-Token", service- > >sessionToken); > - ASSERT_EFI_ERROR (Status); > - } else if (service->basicAuthStr) { > - Status =3D HttpIoSetHeader (HttpIoHeader, "Authorization", service- > >basicAuthStr); > - ASSERT_EFI_ERROR (Status); > - } > - > - Status =3D HttpIoSetHeader (HttpIoHeader, "Host", service- > >HostHeaderValue); > - ASSERT_EFI_ERROR (Status); > - Status =3D HttpIoSetHeader (HttpIoHeader, "OData-Version", "4.0"); > - ASSERT_EFI_ERROR (Status); > - Status =3D HttpIoSetHeader (HttpIoHeader, "Accept", "application/json"= ); > - ASSERT_EFI_ERROR (Status); > - Status =3D HttpIoSetHeader (HttpIoHeader, "User-Agent", "libredfish"); > - ASSERT_EFI_ERROR (Status); > - Status =3D HttpIoSetHeader (HttpIoHeader, "Connection", "Keep-Alive"); > - ASSERT_EFI_ERROR (Status); > - > - // > - // Step 2: build the rest of HTTP request info. > - // > - RequestData =3D AllocateZeroPool (sizeof (EFI_HTTP_REQUEST_DATA)); > - if (RequestData =3D=3D NULL) { > - ret =3D NULL; > - goto ON_EXIT; > - } > - > - RequestData->Method =3D HttpMethodGet; > - RequestData->Url =3D C8ToC16 (url); > - > - // > - // Step 3: fill in EFI_HTTP_MESSAGE > - // > - RequestMsg =3D AllocateZeroPool (sizeof (EFI_HTTP_MESSAGE)); > - if (RequestMsg =3D=3D NULL) { > - ret =3D NULL; > - goto ON_EXIT; > - } > - > - RequestMsg->Data.Request =3D RequestData; > - RequestMsg->HeaderCount =3D HttpIoHeader->HeaderCount; > - RequestMsg->Headers =3D HttpIoHeader->Headers; > - > - ZeroMem (&ResponseMsg, sizeof (ResponseMsg)); > + // > + // The caller shall take the responsibility to free the buffer. > + // > + **StatusCode =3D ResponseMsg.Data.Response->StatusCode; > + } > > - // > - // Step 4: call RESTEx to get response from REST service. > - // > - Status =3D service->RestEx->SendReceive (service->RestEx, RequestMsg, > &ResponseMsg); > - if (EFI_ERROR (Status)) { > - ret =3D NULL; > goto ON_EXIT; > } > > @@ -703,6 +566,10 @@ getUriFromService ( > **StatusCode =3D ResponseMsg.Data.Response->StatusCode; > } > > + if ((ResponseMsg.Headers !=3D NULL) && (Headers !=3D NULL) && > (HeaderCount !=3D NULL)) { > + *Headers =3D cloneHttpHeaders (&ResponseMsg, HeaderCount); > + } > + > if ((ResponseMsg.BodyLength !=3D 0) && (ResponseMsg.Body !=3D NULL)) { > // > // Check if data is encoded. > @@ -751,12 +618,14 @@ ON_EXIT: > } > > json_t * > -patchUriFromServiceEx ( > +putUriFromServiceEx ( > redfishService *service, > const char *uri, > const char *content, > - EFI_HTTP_HEADER **Headers, > - UINTN *HeaderCount, > + size_t contentLength, > + const char *contentType, > + EFI_HTTP_HEADER **Headers OPTIONAL, > + UINTN *HeaderCount OPTIONAL, > EFI_HTTP_STATUS_CODE **StatusCode > ) > { > @@ -776,18 +645,29 @@ patchUriFromServiceEx ( > } > > *StatusCode =3D NULL; > + if (HeaderCount !=3D NULL) { > + *HeaderCount =3D 0; > + } > + > + if (Headers !=3D NULL) { > + *Headers =3D NULL; > + } > > url =3D makeUrlForService (service, uri); > - if (!url) { > + if (url =3D=3D NULL) { > return NULL; > } > > - DEBUG ((DEBUG_MANAGEABILITY, "libredfish: patchUriFromService(): > %a\n", url)); > + DEBUG ((DEBUG_MANAGEABILITY, "%a: %a\n", __func__, url)); > + > + if (contentLength =3D=3D 0) { > + contentLength =3D strlen (content); > + } > > // > // Step 1: Create HTTP request message with 4 headers: > // > - HttpIoHeader =3D HttpIoCreateHeader ((service->sessionToken || service= - > >basicAuthStr) ? 9 : 8); > + HttpIoHeader =3D HttpIoCreateHeader ((service->sessionToken !=3D NULL = || > service->basicAuthStr !=3D NULL) ? 9 : 8); > if (HttpIoHeader =3D=3D NULL) { > ret =3D NULL; > goto ON_EXIT; > @@ -801,6 +681,14 @@ patchUriFromServiceEx ( > ASSERT_EFI_ERROR (Status); > } > > + if (contentType =3D=3D NULL) { > + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Type", > "application/json"); > + ASSERT_EFI_ERROR (Status); > + } else { > + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Type", (CHAR8 > *)contentType); > + ASSERT_EFI_ERROR (Status); > + } > + > Status =3D HttpIoSetHeader (HttpIoHeader, "Host", service->HostHeaderV= alue); > ASSERT_EFI_ERROR (Status); > Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Type", > "application/json"); > @@ -816,7 +704,7 @@ patchUriFromServiceEx ( > ContentLengthStr, > sizeof (ContentLengthStr), > "%lu", > - (UINT64)strlen (content) > + (UINT64)contentLength > ); > Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Length", > ContentLengthStr); > ASSERT_EFI_ERROR (Status); > @@ -832,7 +720,7 @@ patchUriFromServiceEx ( > goto ON_EXIT; > } > > - RequestData->Method =3D HttpMethodPatch; > + RequestData->Method =3D HttpMethodPut; > RequestData->Url =3D C8ToC16 (url); > > // > @@ -845,7 +733,7 @@ patchUriFromServiceEx ( > } > > EncodedContent =3D (CHAR8 *)content; > - EncodedContentLen =3D strlen (content); > + EncodedContentLen =3D contentLength; > // > // We currently only support gzip Content-Encoding. > // > @@ -896,7 +784,7 @@ patchUriFromServiceEx ( > **StatusCode =3D ResponseMsg.Data.Response->StatusCode; > } > > - if (ResponseMsg.Headers !=3D NULL) { > + if ((ResponseMsg.Headers !=3D NULL) && (Headers !=3D NULL) && > (HeaderCount !=3D NULL)) { > *Headers =3D cloneHttpHeaders (&ResponseMsg, HeaderCount); > } > > @@ -936,10 +824,12 @@ ON_EXIT: > } > > json_t * > -patchUriFromService ( > +patchUriFromServiceEx ( > redfishService *service, > const char *uri, > const char *content, > + EFI_HTTP_HEADER **Headers OPTIONAL, > + UINTN *HeaderCount OPTIONAL, > EFI_HTTP_STATUS_CODE **StatusCode > ) > { > @@ -959,13 +849,20 @@ patchUriFromService ( > } > > *StatusCode =3D NULL; > + if (HeaderCount !=3D NULL) { > + *HeaderCount =3D 0; > + } > + > + if (Headers !=3D NULL) { > + *Headers =3D NULL; > + } > > url =3D makeUrlForService (service, uri); > if (!url) { > return NULL; > } > > - DEBUG ((DEBUG_MANAGEABILITY, "libredfish: patchUriFromService(): > %a\n", url)); > + DEBUG ((DEBUG_MANAGEABILITY, "%a: %a\n", __func__, url)); > > // > // Step 1: Create HTTP request message with 4 headers: > @@ -1079,6 +976,10 @@ patchUriFromService ( > **StatusCode =3D ResponseMsg.Data.Response->StatusCode; > } > > + if ((ResponseMsg.Headers !=3D NULL) && (Headers !=3D NULL) && > (HeaderCount !=3D NULL)) { > + *Headers =3D cloneHttpHeaders (&ResponseMsg, HeaderCount); > + } > + > if (EncodedContent !=3D content) { > FreePool (EncodedContent); > } > @@ -1121,8 +1022,8 @@ postUriFromServiceEx ( > const char *content, > size_t contentLength, > const char *contentType, > - EFI_HTTP_HEADER **Headers, > - UINTN *HeaderCount, > + EFI_HTTP_HEADER **Headers OPTIONAL, > + UINTN *HeaderCount OPTIONAL, > EFI_HTTP_STATUS_CODE **StatusCode > ) > { > @@ -1143,13 +1044,20 @@ postUriFromServiceEx ( > } > > *StatusCode =3D NULL; > + if (HeaderCount !=3D NULL) { > + *HeaderCount =3D 0; > + } > + > + if (Headers !=3D NULL) { > + *Headers =3D NULL; > + } > > url =3D makeUrlForService (service, uri); > if (!url) { > return NULL; > } > > - DEBUG ((DEBUG_MANAGEABILITY, "libredfish: postUriFromService(): > %a\n", url)); > + DEBUG ((DEBUG_MANAGEABILITY, "%a: %a\n", __func__, url)); > > if (contentLength =3D=3D 0) { > contentLength =3D strlen (content); > @@ -1230,7 +1138,12 @@ postUriFromServiceEx ( > // > Status =3D service->RestEx->SendReceive (service->RestEx, RequestMsg, > &ResponseMsg); > if (EFI_ERROR (Status)) { > - goto ON_EXIT; > + // > + // If there is no response to handle, go to error exit. > + // > + if (ResponseMsg.Data.Response =3D=3D NULL) { > + goto ON_EXIT; > + } > } > > // > @@ -1248,7 +1161,7 @@ postUriFromServiceEx ( > **StatusCode =3D ResponseMsg.Data.Response->StatusCode; > } > > - if (ResponseMsg.Headers !=3D NULL) { > + if ((ResponseMsg.Headers !=3D NULL) && (Headers !=3D NULL) && > (HeaderCount !=3D NULL)) { > *Headers =3D cloneHttpHeaders (&ResponseMsg, HeaderCount); > } > > @@ -1257,10 +1170,11 @@ postUriFromServiceEx ( > } > > // > - // Step 6: Parsing the HttpHeader to retrive the X-Auth-Token if the H= TTP > StatusCode is correct. > + // Step 6: Parsing the HttpHeader to retrieve the X-Auth-Token if the = HTTP > StatusCode is correct. > // > - if ((ResponseMsg.Data.Response->StatusCode =3D=3D HTTP_STATUS_200_OK) > || > - (ResponseMsg.Data.Response->StatusCode =3D=3D > HTTP_STATUS_204_NO_CONTENT)) > + if ((ResponseMsg.Data.Response !=3D NULL) && > + ((ResponseMsg.Data.Response->StatusCode =3D=3D HTTP_STATUS_200_OK) > || > + (ResponseMsg.Data.Response->StatusCode =3D=3D > HTTP_STATUS_204_NO_CONTENT))) > { > HttpHeader =3D HttpFindHeader (ResponseMsg.HeaderCount, > ResponseMsg.Headers, "X-Auth-Token"); > if (HttpHeader !=3D NULL) { > @@ -1270,19 +1184,6 @@ postUriFromServiceEx ( > > service->sessionToken =3D AllocateCopyPool (AsciiStrSize (HttpHead= er- > >FieldValue), HttpHeader->FieldValue); > } > - > - /* > - // > - // Below opeation seems to be unnecessary. > - // Besides, the FieldValue for the Location is the full HTTP URI > (Http://0.0.0.0:5000/XXX), so we can't use it as the > - // parameter of getUriFromService () directly. > - // > - HttpHeader =3D HttpFindHeader (ResponseMsg.HeaderCount, > ResponseMsg.Headers, "Location"); > - if (HttpHeader !=3D NULL) { > - ret =3D getUriFromService(service, HttpHeader->FieldValue); > - goto ON_EXIT; > - } > - */ > } > > ON_EXIT: > @@ -1307,6 +1208,27 @@ ON_EXIT: > return ret; > } > > +json_t * > +getUriFromService ( > + redfishService *service, > + const char *uri, > + EFI_HTTP_STATUS_CODE **StatusCode > + ) > +{ > + return getUriFromServiceEx (service, uri, NULL, NULL, StatusCode); > +} > + > +json_t * > +patchUriFromService ( > + redfishService *service, > + const char *uri, > + const char *content, > + EFI_HTTP_STATUS_CODE **StatusCode > + ) > +{ > + return patchUriFromServiceEx (service, uri, content, NULL, NULL, > StatusCode); > +} > + > json_t * > postUriFromService ( > redfishService *service, > @@ -1317,187 +1239,14 @@ postUriFromService ( > EFI_HTTP_STATUS_CODE **StatusCode > ) > { > - char *url =3D NULL; > - json_t *ret; > - HTTP_IO_HEADER *HttpIoHeader =3D NULL; > - EFI_STATUS Status; > - EFI_HTTP_REQUEST_DATA *RequestData =3D NULL; > - EFI_HTTP_MESSAGE *RequestMsg =3D NULL; > - EFI_HTTP_MESSAGE ResponseMsg; > - CHAR8 ContentLengthStr[80]; > - EFI_HTTP_HEADER *HttpHeader =3D NULL; > - > - ret =3D NULL; > - > - if ((service =3D=3D NULL) || (uri =3D=3D NULL) || (content =3D=3D NULL= ) || (StatusCode =3D=3D > NULL)) { > - return NULL; > - } > - > - *StatusCode =3D NULL; > - > - url =3D makeUrlForService (service, uri); > - if (!url) { > - return NULL; > - } > - > - DEBUG ((DEBUG_MANAGEABILITY, "libredfish: postUriFromService(): > %a\n", url)); > - > - if (contentLength =3D=3D 0) { > - contentLength =3D strlen (content); > - } > - > - // > - // Step 1: Create HTTP request message with 4 headers: > - // > - HttpIoHeader =3D HttpIoCreateHeader ((service->sessionToken || service= - > >basicAuthStr) ? 8 : 7); > - if (HttpIoHeader =3D=3D NULL) { > - goto ON_EXIT; > - } > - > - if (service->sessionToken) { > - Status =3D HttpIoSetHeader (HttpIoHeader, "X-Auth-Token", service- > >sessionToken); > - ASSERT_EFI_ERROR (Status); > - } else if (service->basicAuthStr) { > - Status =3D HttpIoSetHeader (HttpIoHeader, "Authorization", service- > >basicAuthStr); > - ASSERT_EFI_ERROR (Status); > - } > - > - if (contentType =3D=3D NULL) { > - Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Type", > "application/json"); > - ASSERT_EFI_ERROR (Status); > - } else { > - Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Type", (CHAR8 > *)contentType); > - ASSERT_EFI_ERROR (Status); > - } > - > - Status =3D HttpIoSetHeader (HttpIoHeader, "Host", service- > >HostHeaderValue); > - ASSERT_EFI_ERROR (Status); > - Status =3D HttpIoSetHeader (HttpIoHeader, "Accept", "application/json"= ); > - ASSERT_EFI_ERROR (Status); > - Status =3D HttpIoSetHeader (HttpIoHeader, "User-Agent", "libredfish"); > - ASSERT_EFI_ERROR (Status); > - Status =3D HttpIoSetHeader (HttpIoHeader, "Connection", "Keep-Alive"); > - ASSERT_EFI_ERROR (Status); > - AsciiSPrint ( > - ContentLengthStr, > - sizeof (ContentLengthStr), > - "%lu", > - (UINT64)contentLength > - ); > - Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Length", > ContentLengthStr); > - ASSERT_EFI_ERROR (Status); > - Status =3D HttpIoSetHeader (HttpIoHeader, "OData-Version", "4.0"); > - ASSERT_EFI_ERROR (Status); > - > - // > - // Step 2: build the rest of HTTP request info. > - // > - RequestData =3D AllocateZeroPool (sizeof (EFI_HTTP_REQUEST_DATA)); > - if (RequestData =3D=3D NULL) { > - goto ON_EXIT; > - } > - > - RequestData->Method =3D HttpMethodPost; > - RequestData->Url =3D C8ToC16 (url); > - > - // > - // Step 3: fill in EFI_HTTP_MESSAGE > - // > - RequestMsg =3D AllocateZeroPool (sizeof (EFI_HTTP_MESSAGE)); > - if (RequestMsg =3D=3D NULL) { > - goto ON_EXIT; > - } > - > - RequestMsg->Data.Request =3D RequestData; > - RequestMsg->HeaderCount =3D HttpIoHeader->HeaderCount; > - RequestMsg->Headers =3D HttpIoHeader->Headers; > - RequestMsg->BodyLength =3D contentLength; > - RequestMsg->Body =3D (VOID *)content; > - > - ZeroMem (&ResponseMsg, sizeof (ResponseMsg)); > - > - // > - // Step 4: call RESTEx to get response from REST service. > - // > - Status =3D service->RestEx->SendReceive (service->RestEx, RequestMsg, > &ResponseMsg); > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - // > - // Step 5: Return the HTTP StatusCode and Body message. > - // > - if (ResponseMsg.Data.Response !=3D NULL) { > - *StatusCode =3D AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE)); > - if (*StatusCode =3D=3D NULL) { > - goto ON_EXIT; > - } > - > - // > - // The caller shall take the responsibility to free the buffer. > - // > - **StatusCode =3D ResponseMsg.Data.Response->StatusCode; > - } > - > - if ((ResponseMsg.BodyLength !=3D 0) && (ResponseMsg.Body !=3D NULL)) { > - ret =3D json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NUL= L); > - } > - > - // > - // Step 6: Parsing the HttpHeader to retrive the X-Auth-Token if the H= TTP > StatusCode is correct. > - // > - if ((ResponseMsg.Data.Response->StatusCode =3D=3D HTTP_STATUS_200_OK) > || > - (ResponseMsg.Data.Response->StatusCode =3D=3D > HTTP_STATUS_204_NO_CONTENT)) > - { > - HttpHeader =3D HttpFindHeader (ResponseMsg.HeaderCount, > ResponseMsg.Headers, "X-Auth-Token"); > - if (HttpHeader !=3D NULL) { > - if (service->sessionToken) { > - free (service->sessionToken); > - } > - > - service->sessionToken =3D AllocateCopyPool (AsciiStrSize (HttpHead= er- > >FieldValue), HttpHeader->FieldValue); > - } > - > - /* > - // > - // Below opeation seems to be unnecessary. > - // Besides, the FieldValue for the Location is the full HTTP URI > (Http://0.0.0.0:5000/XXX), so we can't use it as the > - // parameter of getUriFromService () directly. > - // > - HttpHeader =3D HttpFindHeader (ResponseMsg.HeaderCount, > ResponseMsg.Headers, "Location"); > - if (HttpHeader !=3D NULL) { > - ret =3D getUriFromService(service, HttpHeader->FieldValue); > - goto ON_EXIT; > - } > - */ > - } > - > -ON_EXIT: > - if (url !=3D NULL) { > - free (url); > - } > - > - if (HttpIoHeader !=3D NULL) { > - HttpIoFreeHeader (HttpIoHeader); > - } > - > - if (RequestData !=3D NULL) { > - RestConfigFreeHttpRequestData (RequestData); > - } > - > - if (RequestMsg !=3D NULL) { > - FreePool (RequestMsg); > - } > - > - RestConfigFreeHttpMessage (&ResponseMsg, FALSE); > - > - return ret; > + return postUriFromServiceEx (service, uri, content, contentLength, > contentType, NULL, NULL, StatusCode); > } > > json_t * > -deleteUriFromService ( > +deleteUriFromServiceEx ( > redfishService *service, > const char *uri, > + const char *content, > EFI_HTTP_STATUS_CODE **StatusCode > ) > { > @@ -1508,6 +1257,8 @@ deleteUriFromService ( > EFI_HTTP_REQUEST_DATA *RequestData =3D NULL; > EFI_HTTP_MESSAGE *RequestMsg =3D NULL; > EFI_HTTP_MESSAGE ResponseMsg; > + CHAR8 ContentLengthStr[80]; > + size_t contentLength; > > ret =3D NULL; > > @@ -1527,7 +1278,7 @@ deleteUriFromService ( > // > // Step 1: Create HTTP request message with 4 headers: > // > - HttpIoHeader =3D HttpIoCreateHeader ((service->sessionToken || service= - > >basicAuthStr) ? 5 : 4); > + HttpIoHeader =3D HttpIoCreateHeader ((service->sessionToken || service= - > >basicAuthStr) ? 8 : 7); > if (HttpIoHeader =3D=3D NULL) { > ret =3D NULL; > goto ON_EXIT; > @@ -1550,6 +1301,23 @@ deleteUriFromService ( > Status =3D HttpIoSetHeader (HttpIoHeader, "Connection", "Keep-Alive"); > ASSERT_EFI_ERROR (Status); > > + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Type", > "application/json"); > + ASSERT_EFI_ERROR (Status); > + > + if (content !=3D NULL) { > + contentLength =3D strlen (content); > + AsciiSPrint ( > + ContentLengthStr, > + sizeof (ContentLengthStr), > + "%lu", > + (UINT64)contentLength > + ); > + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Length", > ContentLengthStr); > + ASSERT_EFI_ERROR (Status); > + Status =3D HttpIoSetHeader (HttpIoHeader, "OData-Version", "4.0"); > + ASSERT_EFI_ERROR (Status); > + } > + > // > // Step 2: build the rest of HTTP request info. > // > @@ -1575,6 +1343,11 @@ deleteUriFromService ( > RequestMsg->HeaderCount =3D HttpIoHeader->HeaderCount; > RequestMsg->Headers =3D HttpIoHeader->Headers; > > + if (content !=3D NULL) { > + RequestMsg->BodyLength =3D contentLength; > + RequestMsg->Body =3D (VOID *)content; > + } > + > ZeroMem (&ResponseMsg, sizeof (ResponseMsg)); > > // > @@ -1628,6 +1401,16 @@ ON_EXIT: > return ret; > } > > +json_t * > +deleteUriFromService ( > + redfishService *service, > + const char *uri, > + EFI_HTTP_STATUS_CODE **StatusCode > + ) > +{ > + return deleteUriFromServiceEx (service, uri, NULL, StatusCode); > +} > + > redfishPayload * > getRedfishServiceRoot ( > redfishService *service, > @@ -2034,6 +1817,10 @@ makeUrlForService ( > } > > url =3D (char *)malloc (strlen (service->host)+strlen (uri)+1); > + if (url =3D=3D NULL) { > + return NULL; > + } > + > strcpy (url, service->host); > strcat (url, uri); > return url; > -- > 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110465): https://edk2.groups.io/g/devel/message/110465 Mute This Topic: https://groups.io/mt/102196088/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-