From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.41]) by mx.groups.io with SMTP id smtpd.web08.28458.1658976671162842908 for ; Wed, 27 Jul 2022 19:51:11 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=zpJq2ZN7; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.236.41, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g5x9X8jQGUbTIfqt11uaJYe4B2fSVob6/WteW4RU61a3ueDd+ZxgE0mwCvH9ITrCYKyeKZR+tCn5iV9OEMb1NESW3eM+VwXjIeVSzIIyBxBODZfLqLsDBZbmGzyEbkj/FSGSfDhEjPM4jIGi97TtGxqhKFABIjvRODbUg1w4bLzAAmo1V5NjkXUgZrLkjUnAfiGvWo2uqb1s5StBqWXzTSMn22j5ufbDdS6yUmpnfTse3c16K5Fdf18fg002mSJ7xPwuPe7OpSbGQZ5FGQ4Zme0rBbTC+be7ztz0jIUrsFKnkn4sPBbZeGCNK9D3JbPohsMn0w2z2rrxMe6n+gwe2A== 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=6b6xZdLBUJV4PYzWqbQqgsIPHNtS+nNPZYr2hEifXf0=; b=LADcTy9uSmrIN4AYk1MbpjwGtxB2SxA6qdKQT5E/C18r+oyQH2MJF3xhFVx4Ec9ao29QwQslFEFOesiuBIDfgSqkReQJKUVbIvLV8rtOU9U+62goM/VPa8ti00v7Qmq/25uqcaV36oNWmjUj3QbtpayKjAhCKv/JYv/e/Gmauecr3FQW7cBwQnUMPV0iGFkU04NtrKBUu5Oh0065qWZ6bFVEutFcP7a09xGzE2fGJhyuCY+hf+4PUOCm/vzHSc08UVTniEUAZ/4wd7uEEtlyKi62Vs9353z6Ul/RDhM37NPJ9yZuRcrt53FlGzygR8ngDJyXPnUFkISscfzYHrMuvQ== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6b6xZdLBUJV4PYzWqbQqgsIPHNtS+nNPZYr2hEifXf0=; b=zpJq2ZN7vc4t3Gw+8OVKYUrRFZiZgwzQTVJeOrEkuVk8MGH0Ik4B73tXiR6ddmKKeCYgl33qZYY3dnkuzvumG3MQK1QzbPCt+6Y92Ys/7CVU8W4bYNsvgF5Ne302FIFbhPDsWk5w78Gt6Am8Ay/A00YBexROEmaW0D6gyP+KzAg= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by DM6PR12MB4339.namprd12.prod.outlook.com (2603:10b6:5:2af::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Thu, 28 Jul 2022 02:51:07 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::605a:11f4:fc16:8b06]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::605a:11f4:fc16:8b06%5]) with mapi id 15.20.5458.025; Thu, 28 Jul 2022 02:51:07 +0000 From: "Chang, Abner" To: Nickle Wang , "devel@edk2.groups.io" CC: "Yang, Atom" , Nick Ramirez Subject: Re: [edk2-staging][PATCH v3 09/15] edk2-staging/RedfishClientPkg: Update RedfishLib Thread-Topic: [edk2-staging][PATCH v3 09/15] edk2-staging/RedfishClientPkg: Update RedfishLib Thread-Index: AQHYoVmPs5mGyXl4NUib+pevjrlZ362TFvgg Date: Thu, 28 Jul 2022 02:51:06 +0000 Message-ID: References: <20220727013802.247-1-nickle.wang@hpe.com> <20220727013802.247-10-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-10-nickle.wang@hpe.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2022-07-28T02:51:00Z; 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_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=b2120200-fe3a-44e1-88d2-506d7fcfa79d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6f3e3848-9c67-4e1b-36e9-08da704404f4 x-ms-traffictypediagnostic: DM6PR12MB4339:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qEZ936atjeVd4EJkkobsGWmB6TRMBMYC+GhLI53gjhsyFY5lECN4Mh8wplVFVyenMqO1IKJJGFFeeWBt0omSllktWFB6LO4bPHJud0Mn28svsqV7qGXxxCmfjSLNDyIhYmo1pvPBBdDIaA64zGmxeipnCMH3BUchnuX5q/R1emyhbsvCK2FahlWYr+AIaXcCjUWJO9vTfBlSoF3gqCwIKRPMas3tRgjgJZnVLrXfuAdxt/4VMY5RR19FzEB3kcelLcHCWcrX5zFkTy0B5fd0hMhCsp905OZpm8Woc5Uq72JupC99SZTm9h8szKA5Y6kbvE3dRXe67PraiKu44cVrig1JpkKCXbTKdvsD0paEdB8+TwjnRKNhyyZHGEcrAo5V3ew0jHMwJiAPJ5CQVu/x45c6aBIsc3z850beFi4WL0BaxvE1WMIontRvv4l37LElsjb/bUhIOZ4i37SkI6nMYlt6uToxSytBNpVQ64g5q95/k6BPMwdg9FZ9yo6dKltaqWihaHXUeLQvTiPK6SbFCAQcO3uLpjPV9XEoDuAseS2g28Tueyqvow4RhxdHQz6bdi9KI8dkTyCTgXmGYdqkaajg6k0iE6dih7MMyeYwY6K4392GPn4h+OXhMGA/K6qaimEeleVbtOOzmaDToryEut0z6XAa6f8d4NiK/cHcXdMe6tzygq6Q2COxBVwqJPnsuKF5SI8yYuG7qro6vsxRnifY9h8/mTyPqr9B2eJocYiIA7vX9A0Sw8LkhyE1cjzAcSDGs67Q2qNSoE8ZgDQUWW7krhcAiF1nh/4GjO2fPFTfzwEx1P2unhQfdkPPUH9nhrM5aj5E87xJC088fBh8ww== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3966.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(346002)(396003)(376002)(39860400002)(366004)(136003)(5660300002)(52536014)(8936002)(30864003)(83380400001)(110136005)(33656002)(15650500001)(55016003)(66476007)(296002)(54906003)(66556008)(8676002)(66946007)(64756008)(66446008)(4326008)(316002)(76116006)(38070700005)(6506007)(7696005)(86362001)(2906002)(186003)(45080400002)(71200400001)(122000001)(478600001)(41300700001)(9686003)(53546011)(26005)(38100700002)(559001)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?51fiUzUiw/jXepwWl3TlHQcSW5s5W/tFWa2eBtzyjIk8wSYFgDof5Em1511J?= =?us-ascii?Q?kuWGB+vw6AqdHqEkRGDIYHZi7b8z1Vju8zxidCj+JIuO3k4qCtbxcXfSlD5p?= =?us-ascii?Q?5Daa3qaGgSnTc8M3f0Z4/ld0l+zBkNiNXgKUCyTpFWmRpKXWE6FavN5vyR5f?= =?us-ascii?Q?754GjxnkcAOCxPeuX2sDsecHuY4r1IBxnrbQxPoVIRjRGZd2KnJkIOyLZNA9?= =?us-ascii?Q?NSfIuVDHgMB+sm7wrVDu+sfJ7tgkM0qX41WAsll14pEcNkR2pfSQC+EOayqC?= =?us-ascii?Q?+ddyqCMkP+J2QqtXlpomE1tUDOnNlAuM7zySt6/lLCkeSRgvh2LoT8Qc3/yG?= =?us-ascii?Q?0Wiqvn4cz5R6zPbhY17ZtDdY/VftuW1kafqb1QmNhyt27HtVhEbngv4GY9Wq?= =?us-ascii?Q?mvBS5wCRIoX2UwC+kQgOcu+suPxlOrG7ix4WgiIi+UcUx+448OArVpyH7hW2?= =?us-ascii?Q?oI+HTP9Tch15sgVqfPv8Fv+VO7bih3an9a1w/usIeCEMlTrBATUkhtzoObPL?= =?us-ascii?Q?ZVhV/v4bCGBZWHDX9612i5JXDIkmawjEO1sV6fSlRNBDmwFkwDN325XF4RLn?= =?us-ascii?Q?caxj4NNoTWvTpSbA3AzsbmTbCllIrefXgv0ZpRggClizggxAK2UGU5duSImn?= =?us-ascii?Q?zZ5S2WZ8x6pK4qzWE3OBcSgPt2300qz4Tv9lGXjnAc/uOdZSk4flXkIzFOrD?= =?us-ascii?Q?3wSNpfU3f/cmr8vPzBWox/YTIV2002gmoVHjKslIEPXld+uC/hrUZJUzQME6?= =?us-ascii?Q?v7xRFLE81B5Q80bXU+qfA19uTTW6te+72tGK/Fs1lm1eH2CBuOXN1lV57W9y?= =?us-ascii?Q?7Ekna2L9JAZ28CdzrM6WgvxHB0/lSr0Pw6oX4HLpinZ0/bNFa6FUJPVAXkGR?= =?us-ascii?Q?YI4F/26mzDe6BIEpJR0jgPuwbnZuoxAPtH1/TaSC+meSAXKLSrsis733bPLh?= =?us-ascii?Q?cddzW1W3cjOJU5DJmJ/YEeSxhe6gHa144XDrTc+KB68RpCVqTOc00X84OA0d?= =?us-ascii?Q?QyUf6IfQMSukTsX2nYrxhgjuZ45xFS9GbuEoRsE/Cr6RYaHKnp2Ua/OoxriB?= =?us-ascii?Q?337PzFSkSIb0RFyWRqqQU5CarIfyE2U9UJIri2j1JcuhArpPZde5ZedxdJxL?= =?us-ascii?Q?ufk+/RAL129WdfVXnkK+LTJXqkI5uWkNzUJnW/RSUty4L7kfPu9s8qoVLc5h?= =?us-ascii?Q?OOtllvf2jYh5HZnkwo4I+BF5fZK8jWq7Fl3IgEvR+E3YyXhA+SAL71W2q/XR?= =?us-ascii?Q?7DFfr90ijkKbyMAnpjL3KrhDQjXzdqDEe0DAUK2yNfRdBRaMBSfhjHrTKJb0?= =?us-ascii?Q?YbnHXF08+aj/eNZEHrpyjBuSW2i1wDaNXUXVNmi5o6xkeB/uoekS9J/cnbNj?= =?us-ascii?Q?ufElM2rHOhS6dwJe+34wZ6fNRCrLkXlnZ8+ZbiH+W1ufsASEOfHXvWPRC9IZ?= =?us-ascii?Q?ijyRocZc56dAaP7If3i96UmkpO6j+K4ZqDNeSMMY5frJz7UaFBU2W2/H+3J9?= =?us-ascii?Q?qPFhzT5fsbWzyQe9a/xsOG1bGQGLvnXnFMCYXITaonFJwgHLCHQR8o5zSwRM?= =?us-ascii?Q?mPDcXvo8ysPBBcKYq40=3D?= 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: 6f3e3848-9c67-4e1b-36e9-08da704404f4 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jul 2022 02:51:06.9078 (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: uN+aXtkmTyQ8a/+JkP5oBQ1O4OchExGKdKm97TuHrd+VGQT1RjzXwUxf+CLo6mjN8/XRvk4l13sNdzIEFZVUSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4339 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Reviewed-by: Abner Chang > -----Original Message----- > From: Nickle Wang > Sent: Wednesday, July 27, 2022 9:38 AM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Yang, Atom > ; Nick Ramirez > Subject: [edk2-staging][PATCH v3 09/15] edk2-staging/RedfishClientPkg: > Update RedfishLib >=20 > [CAUTION: External Email] >=20 > RedfishLib has no capability to return HTTP header in response. > However, feature driver needs to know the information like "ETag" or > "Location" in HTTP response header per Redfish specification. Add > corresponding function to return HTTP header in response data. >=20 > Signed-off-by: Nickle Wang > Cc: Abner Chang > Cc: Yang Atom > Cc: Nick Ramirez > --- > .../PrivateLibrary/RedfishLib/RedfishLib.c | 12 +- > .../edk2libredfish/include/redfishPayload.h | 5 +- > .../edk2libredfish/include/redfishService.h | 5 +- > .../RedfishLib/edk2libredfish/src/payload.c | 90 ++- > .../RedfishLib/edk2libredfish/src/service.c | 554 +++++++++++++++++- > 5 files changed, 657 insertions(+), 9 deletions(-) >=20 > diff --git a/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.c > b/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.c > index 18aa4646e8..b8ca493e24 100644 > --- a/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.c > +++ b/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.c > @@ -3,7 +3,7 @@ > (CRUD) Redfish resources and provide basic query. >=20 > Copyright (c) 2019, Intel Corporation. All rights reserved.
> - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> + (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -323,7 +323,7 @@ RedfishGetByUri ( >=20 > ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); >=20 > - JsonValue =3D getUriFromService (RedfishService, Uri, &RedResponse- > >StatusCode); > + JsonValue =3D getUriFromServiceEx (RedfishService, Uri, > + &RedResponse->Headers, &RedResponse->HeaderCount, > + &RedResponse->StatusCode); > RedResponse->Payload =3D createRedfishPayload(JsonValue, RedfishServic= e); >=20 > // > @@ -541,9 +541,11 @@ RedfishPatchToPayload ( >=20 > ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); >=20 > - RedResponse->Payload =3D (REDFISH_PAYLOAD) patchPayload ( > + RedResponse->Payload =3D (REDFISH_PAYLOAD) patchPayloadEx ( > Target, > Payload, > + &RedResponse->Headers, > + &RedResponse->HeaderCount, > &(RedResponse->StatusCode) > ); >=20 > @@ -607,9 +609,11 @@ RedfishPostToPayload ( >=20 > ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); >=20 > - RedResponse->Payload =3D (REDFISH_PAYLOAD) postPayload ( > + RedResponse->Payload =3D (REDFISH_PAYLOAD) postPayloadEx ( > Target, > Payload, > + &RedResponse->Headers, > + &RedResponse->HeaderCount, > &(RedResponse->StatusCode) > ); >=20 > diff --git > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= sh > Payload.h > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= sh > Payload.h > index 43149f3c89..be74c64297 100644 > --- > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= sh > Payload.h > +++ b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/ > +++ redfishPayload.h > @@ -9,7 +9,7 @@ > //----------------------------------------------------------------------= ------ >=20 > Copyright (c) 2019, Intel Corporation. All rights reserved.
> - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> + (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -29,8 +29,11 @@ redfishPayload* getPayloadByIndex(redfishPayload* > payload, size_t index, EFI_HTT > redfishPayload* getPayloadForPath(redfishPayload* payload, > redPathNode* redpath, EFI_HTTP_STATUS_CODE** StatusCode); > redfishPayload* getPayloadForPathString(redfishPayload* payload, const > char* string, EFI_HTTP_STATUS_CODE** StatusCode); > redfishPayload* patchPayload(redfishPayload* target, redfishPayload* > payload, 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, const char* > data, size_t dataSize, const char* contentType, 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, redfishPayload* > payload, 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); > bool isPayloadCollection (redfishPayload *Payload); > size_t getCollectionSize(redfishPayload* payload); > diff --git > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= sh > Service.h > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= sh > Service.h > index 0215caccfc..3d87fad85a 100644 > --- > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= sh > Service.h > +++ b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/ > +++ redfishService.h > @@ -9,7 +9,7 @@ > //----------------------------------------------------------------------= ------ >=20 > Copyright (c) 2019, Intel Corporation. All rights reserved.
> - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> + (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -91,8 +91,11 @@ typedef struct { > #define REDFISH_FLAG_SERVICE_NO_VERSION_DOC 0x00000001 //The > Redfish Service lacks the version document (in violation of the Redfish s= pec) > redfishService* > createServiceEnumerator(REDFISH_CONFIG_SERVICE_INFORMATION > *RedfishConfigServiceInfo, const char* rootUri, enumeratorAuthentication* > auth, unsigned int flags); > json_t* getUriFromService(redfishService* service, const char* uri, > EFI_HTTP_STATUS_CODE** StatusCode); > +json_t* getUriFromServiceEx(redfishService* service, const char* uri, > +EFI_HTTP_HEADER **Headers, UINTN *HeaderCount, > EFI_HTTP_STATUS_CODE > +**StatusCode); > json_t* patchUriFromService(redfishService* service, const char* uri, co= nst > char* content, EFI_HTTP_STATUS_CODE** StatusCode); > +json_t* patchUriFromServiceEx(redfishService* service, const char* uri, > +const char* content, EFI_HTTP_HEADER **Headers, UINTN *HeaderCount, > +EFI_HTTP_STATUS_CODE** StatusCode); > json_t* postUriFromService(redfishService* service, const char* uri, con= st > char* content, size_t contentLength, const char* contentType, > EFI_HTTP_STATUS_CODE** StatusCode); > +json_t* postUriFromServiceEx(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, const char* uri, > EFI_HTTP_STATUS_CODE** StatusCode); > redfishPayload* getRedfishServiceRoot(redfishService* service, const cha= r* > version, EFI_HTTP_STATUS_CODE** StatusCode); > redfishPayload* getPayloadByPath(redfishService* service, const char* pa= th, > EFI_HTTP_STATUS_CODE** StatusCode); diff --git > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c > index bd8d143c4e..8b49bec0df 100644 > --- > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c > +++ b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payl > +++ oad.c > @@ -9,7 +9,7 @@ > //----------------------------------------------------------------------= ------ >=20 > Copyright (c) 2019, Intel Corporation. All rights reserved.
> - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> + (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -326,6 +326,40 @@ redfishPayload* > getPayloadForPathString(redfishPayload* payload, const char* str > return ret; > } >=20 > +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 N= ULL) > + { > + 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, redfishPayload* > payload, EFI_HTTP_STATUS_CODE** StatusCode) { > json_t* json; > @@ -360,6 +394,38 @@ redfishPayload* patchPayload(redfishPayload* > target, redfishPayload* payload, EF > return createRedfishPayload(json, target->service); } >=20 > +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, const char* > data, size_t dataSize, const char* contentType, EFI_HTTP_STATUS_CODE** > StatusCode) { > json_t* json; > @@ -392,6 +458,28 @@ redfishPayload* > postContentToPayload(redfishPayload* target, const char* data, s > return createRedfishPayload(json, target->service); } >=20 > +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), NUL= L, > Headers, HeaderCount, StatusCode); > + free(content); > + return ret; > +} > + > redfishPayload* postPayload(redfishPayload* target, redfishPayload* > payload, EFI_HTTP_STATUS_CODE** StatusCode) { > char* content; > diff --git > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c > index 7713f89e6d..450fa78bbd 100644 > --- a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/servi= ce.c > +++ b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/serv > +++ ice.c > @@ -9,7 +9,7 @@ > //----------------------------------------------------------------------= ------ >=20 > Copyright (c) 2019, Intel Corporation. All rights reserved.
> - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> + (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -338,6 +338,190 @@ ON_EXIT: > return ret; > } >=20 > +EFI_HTTP_HEADER *cloneHttpHeaders(EFI_HTTP_MESSAGE *message, > UINTN > +*HeaderCount) { > + EFI_HTTP_HEADER *Buffer; > + UINTN Index; > + > + if (message =3D=3D NULL || HeaderCount =3D=3D NULL) { > + return NULL; > + } > + > + *HeaderCount =3D message->HeaderCount; > + Buffer =3D AllocatePool (sizeof (EFI_HTTP_HEADER) * > + message->HeaderCount); if (Buffer =3D=3D NULL) { > + return NULL; > + } > + > + for (Index =3D 0; Index < message->HeaderCount; Index++) { > + Buffer[Index].FieldName =3D AllocateCopyPool (AsciiStrSize (message- > >Headers[Index].FieldName), message->Headers[Index].FieldName); > + ASSERT (Buffer[Index].FieldName !=3D NULL); > + Buffer[Index].FieldValue =3D AllocateCopyPool (AsciiStrSize (message= - > >Headers[Index].FieldValue), message->Headers[Index].FieldValue); > + ASSERT (Buffer[Index].FieldValue !=3D NULL); } > + > + return Buffer; > +} > + > +json_t* getUriFromServiceEx(redfishService* service, const char* uri, > +EFI_HTTP_HEADER **Headers, UINTN *HeaderCount, > 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 || Headers =3D=3D NULL || He= aderCount > + =3D=3D NULL ||StatusCode =3D=3D NULL) { > + return NULL; > + } > + > + *StatusCode =3D NULL; > + *HeaderCount =3D 0; > + *Headers =3D NULL; > + > + url =3D makeUrlForService(service, uri); > + if(!url) > + { > + return NULL; > + } > + > + DEBUG((DEBUG_INFO, "libredfish: getUriFromServiceEx(): %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)); > + > + // > + // 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; > + } > + > + // > + // 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. > + // > + **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.", __FUNCTION__, Status)); > + ret =3D NULL; > + goto ON_EXIT; > + } > + } > + ret =3D json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, > + NULL); } 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; > @@ -491,7 +675,7 @@ ON_EXIT: > return ret; > } >=20 > -json_t* patchUriFromService(redfishService* service, const char* uri, co= nst > char* content, EFI_HTTP_STATUS_CODE** StatusCode) > +json_t* patchUriFromServiceEx(redfishService* service, const char* uri, > +const char* content, EFI_HTTP_HEADER **Headers, UINTN *HeaderCount, > +EFI_HTTP_STATUS_CODE** StatusCode) > { > char* url; > json_t* ret; > @@ -632,6 +816,10 @@ json_t* patchUriFromService(redfishService* > service, const char* uri, const char > **StatusCode =3D ResponseMsg.Data.Response->StatusCode; > } >=20 > + if (ResponseMsg.Headers !=3D NULL) { > + *Headers =3D cloneHttpHeaders (&ResponseMsg, HeaderCount); } > + > if (EncodedContent !=3D content) { > FreePool (EncodedContent); > } > @@ -668,6 +856,368 @@ ON_EXIT: > return ret; > } >=20 > +json_t* patchUriFromService(redfishService* service, const char* uri, > +const char* content, 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; > + CHAR8 ContentLengthStr[80]; > + CHAR8 *EncodedContent; > + UINTN EncodedContentLen; > + > + if(service =3D=3D NULL || uri =3D=3D NULL || content =3D=3D NULL || St= atusCode =3D=3D > + NULL) { > + return NULL; > + } > + > + *StatusCode =3D NULL; > + > + url =3D makeUrlForService(service, uri); > + if(!url) > + { > + return NULL; > + } > + > + DEBUG((DEBUG_INFO, "libredfish: patchUriFromService(): %a\n", url)); > + > + // > + // Step 1: Create HTTP request message with 4 headers: > + // > + HttpIoHeader =3D HttpIoCreateHeader ((service->sessionToken || > + service->basicAuthStr) ? 9 : 8); 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, "Content-Type", "application/json"); > + 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) strlen(content) > + ); > + 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) { > + ret =3D NULL; > + goto ON_EXIT; > + } > + > + RequestData->Method =3D HttpMethodPatch; 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; > + } > + > + EncodedContent =3D (CHAR8 *)content; > + EncodedContentLen =3D strlen(content); > + // > + // We currently only support gzip Content-Encoding. > + // > + Status =3D EncodeRequestContent ((CHAR8 > *)HTTP_CONTENT_ENCODING_GZIP, > + (CHAR8 *)content, (VOID **)&EncodedContent, &EncodedContentLen); if > (Status =3D=3D EFI_INVALID_PARAMETER) { > + DEBUG((DEBUG_ERROR, "%a: Error to encode content.\n", > __FUNCTION__)); > + ret =3D NULL; > + goto ON_EXIT; > + } else if (Status =3D=3D EFI_UNSUPPORTED) { > + DEBUG((DEBUG_INFO, "No content coding for %a! Use raw data > instead.\n", HTTP_CONTENT_ENCODING_GZIP)); > + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Encoding", > HTTP_CONTENT_ENCODING_IDENTITY); > + ASSERT_EFI_ERROR (Status); > + } else { > + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Encoding", > HTTP_CONTENT_ENCODING_GZIP); > + ASSERT_EFI_ERROR (Status); > + } > + > + RequestMsg->Data.Request =3D RequestData; RequestMsg->HeaderCount > =3D > + HttpIoHeader->HeaderCount; > + RequestMsg->Headers =3D HttpIoHeader->Headers; > + RequestMsg->BodyLength =3D EncodedContentLen; > + RequestMsg->Body =3D (VOID*) EncodedContent; > + > + 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)) { > + 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. > + // > + **StatusCode =3D ResponseMsg.Data.Response->StatusCode; > + } > + > + if (EncodedContent !=3D content) { > + FreePool (EncodedContent); > + } > + > + > + if (ResponseMsg.BodyLength !=3D 0 && ResponseMsg.Body !=3D NULL) { > + ret =3D json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, > + NULL); } 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* postUriFromServiceEx(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) { > + 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 || St= atusCode =3D=3D > + NULL) { > + return NULL; > + } > + > + *StatusCode =3D NULL; > + > + url =3D makeUrlForService(service, uri); > + if(!url) > + { > + return NULL; > + } > + > + DEBUG((DEBUG_INFO, "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.Headers !=3D NULL) { > + *Headers =3D cloneHttpHeaders (&ResponseMsg, HeaderCount); } > + > + if (ResponseMsg.BodyLength !=3D 0 && ResponseMsg.Body !=3D NULL) { > + ret =3D json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, > + NULL); } > + > + // > + // 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 > (https://nam11.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2F0.0.0 > .0%3A5000%2FXXX&data=3D05%7C01%7Cabner.chang%40amd.com%7C90 > 03fefe404646f2d91808da6f70b041%7C3dd8961fe4884e608e11a82d994e183d > %7C0%7C0%7C637944827040099707%7CUnknown%7CTWFpbGZsb3d8eyJWIj > oiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3 > 000%7C%7C%7C&sdata=3DtSmhlKBno3bHdyIGn2N5ESjfCdp%2FYUEYC%2F > Kqj9azORg%3D&reserved=3D0), 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; > +} > + > json_t* postUriFromService(redfishService* service, const char* uri, con= st > char* content, size_t contentLength, const char* contentType, > EFI_HTTP_STATUS_CODE** StatusCode) { > char* url =3D NULL; > -- > 2.32.0.windows.2