From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.62]) by mx.groups.io with SMTP id smtpd.web11.11378.1683707169873728825 for ; Wed, 10 May 2023 01:26:10 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=dO1LYhMa; 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.243.62, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Er9AUPu3EACaLxM1+2SjiDCyNry55FDtZdmSc45USqUvA4b0kpeZ8XhzjQQB16aAeTWXVijgrootKFvOO1YABfkbVZrTN2tqj9bJGAPCqjciiDF6rt7Jlvhwh6YeuvhXBfBTO7GTXooBJXKNM+c5sLT3+TjzqfgX3mNeRfZ2unRJnGevTJl/RiHz9DO8965z2fDNuNTqcFcWXPtT1AEkgYghLS3biP6fA38IYQgn4fDTGFp3W3md3Fa0PWoNmASU19Prxn1bp8JPbiMmRFGVU6P3YThHARN8lSgXLYxl18lINyh3mZHaPa8bnJUkfEjUcuTwrMOI1VlcGp04nTJ8Hw== 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=oQNlvcH92nXSC1+bpmj8i54K2+C1/rHRa9o9wZl0D2Q=; b=Yfd0cOyDG+PPKttL/DSEOkMYFrEXTykI398GS/5P1R+/o5h5nQe/sL8XFX1sjBnR9Cctlxq/gkVMNd4o2U9dT/lvOvQXJveUZsib7YgWyyDKkPiJxNzuEdwgyjSM9dFzNB1SoI4HPiDWNqsWyGlN3MUlERdQfU/6+icP6N4MHnU2IxAqUwrA9SjjqteqeBQPB+DKzgLScz+Ix+e9yATKe31oomYmyfkymwd7lyvTELJz9850JtHN8hyc6h+asHnxCrhwmNKdF/gjtQUipfuun10wUJJc4x7cFEAdcdtZ01FVlE62hbxv78f9zkycTHGxUPhM5CZpe6eg7mBtqtBk3g== 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=oQNlvcH92nXSC1+bpmj8i54K2+C1/rHRa9o9wZl0D2Q=; b=dO1LYhMaIjIabtJY9pfyV9L2cu/IJzHAwLJnhD7GeOoR3zjmkqib+qVzAi3dirhKEnmRgF+5pbSsVgJ4fx52DfTOs8TG82glsWRJcHXLhl0sGF6LZ53VhK5G0tzpxP+wRSVo2n0CK2wh3QtRxyFClSU0JOhkW5u+q+0Yy7V+m6k= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by MN2PR12MB4359.namprd12.prod.outlook.com (2603:10b6:208:265::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Wed, 10 May 2023 08:26:07 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::46f1:bdce:a4bc:29e3]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::46f1:bdce:a4bc:29e3%3]) with mapi id 15.20.6363.032; Wed, 10 May 2023 08:26:07 +0000 From: "Chang, Abner" To: Nickle Wang , "devel@edk2.groups.io" CC: Igor Kulchytskyy Subject: Re: [edk2-redfish-client][PATCH 3/4] RedfishClientPkg: Update RedfishLib Thread-Topic: [edk2-redfish-client][PATCH 3/4] RedfishClientPkg: Update RedfishLib Thread-Index: AQHZgxjXBOuMXNW9sEiN4fa6jCEvIq9TK+wA Date: Wed, 10 May 2023 08:26:07 +0000 Message-ID: References: <20230510082356.12379-1-nicklew@nvidia.com> In-Reply-To: <20230510082356.12379-1-nicklew@nvidia.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=2023-05-10T08:26:05Z; 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=e492c332-6882-4b10-bc01-1b56f0e3e14f; 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-traffictypediagnostic: MN2PR12MB3966:EE_|MN2PR12MB4359:EE_ x-ms-office365-filtering-correlation-id: 8ca72bcb-12f3-4b3d-2633-08db513033df x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 3T1jstrDd7fZEEnBdBQqXl0y5ivHYamFpCP/WFQArRz62OsxqvnAgTIfmZA6OsgzUYJKB61BqVfMMtxjwfvbPTfyTjFPzFhvVp+kX4P/SaulwkotfBDREuoZkFcGaMt6sTRlk6UQCfMMKs5ulyLqfZdDJ1qaHvMIvpwCoFxupw455NEHLG9akqRrK38OhwRqRceK0gr3vieaeGQINfFjwo4wDan6BDF8raKN3t6gvQEw/a6F+JXCM8JUfHdDb4QeEKVQLZMXLnYAxUszGv9IyFPGqGibz9sJcUqB7i3HM6JcCWPuQxhg1cXehaaV6xKVsJ43S3aaZw82jj32cdiYOwF9UCtaHUbzvQLqhSsWBZ37KDV/DZNiqsxf6qmkgV2k5RmxFDwaWEvNUofoxgaUBhql47lRBJoWChWVYru8yrLpmw43zJ24T10SGZjKs4QPPFzWCAMK9WbE1Wu4OmVvHxSpWs87XzPnOLm3ttPu2YZP1bAJ6FyKbTwyymE6wpa9CBU3SJ3oVUIpcIMQZrGYd3uy6YA+FPN2Lkfwq2qt6pKmW7kB840fQBPmr70DVz7zQC49EC7jpEemLKC+hoCInU/LHPfPPBMpy9RO5uEQ+Pn8b2r+wLPqCNMACmV1Lqsx 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:(13230028)(6019001)(4636009)(346002)(396003)(39860400002)(376002)(136003)(366004)(279900001)(451199021)(5660300002)(52536014)(478600001)(110136005)(7696005)(15650500001)(71200400001)(41300700001)(8676002)(316002)(8936002)(26005)(6506007)(9686003)(4326008)(66556008)(66476007)(66446008)(64756008)(66946007)(76116006)(53546011)(2906002)(30864003)(83380400001)(186003)(122000001)(55016003)(38070700005)(33656002)(86362001)(38100700002)(21314003)(559001)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?qBETkg2iRlVjA3Puq/AdkxGLTwEKUtqy4d2XJyG/xnth8Ly1u5UcPW6RWt9M?= =?us-ascii?Q?En7Qy8blc0CB4L6uCfsWeHnGR+qjnsn+XWreZAMUWnrWN/+ePYnLzef0sYIm?= =?us-ascii?Q?ol9Ontn8UEvLv3Ts6sTKjkTofoTvNy18WDvLLsUM7m3bFiZuYzHihyl1CWGb?= =?us-ascii?Q?H2jOMZ4OZZ5mV/m1k4db0aPiPyg40c+I/vEJQrJk260v134/p/6R+MW/7X1v?= =?us-ascii?Q?8M4EEy+jS4OkGQoMUnakjlRw7LX7AONwbUP7Qpod9IX5nVwyARGa+sBIAkB+?= =?us-ascii?Q?2hJIGqsi/JVMbJ2gPhw8gWzSIoEqLX12KySaQP544Y4O5C61pzG54HDXKoaw?= =?us-ascii?Q?pwdOKJBQpT37JhZb2T23Q22PNEx0FQf+RysEOBPTAlkw/ZOOfpXa39UDy63/?= =?us-ascii?Q?z2JwK1oHSrawtpBApMsUoHCfg1CYAxLwM5H5R1OIoZjuFl38NqJ7PnxKRGeP?= =?us-ascii?Q?QepkEIN/07k8AdsFmXo4d8hr4oGWKHS9mWSPh1X0nxgmlTj0xscWvzyKdKJe?= =?us-ascii?Q?TPNS5RBSKxwc17QXHJhyvsLXhkP92aE0blw+pCFx8AzFR9EimlYYMKaT3vkJ?= =?us-ascii?Q?uTMHiY3IylBOiYENXbvZLMKLCEtBNgheAoScY6MdGBo2Zkenn0Dh2G4b44ep?= =?us-ascii?Q?ZjBdotq4WibuZpJXhnVD+ZBYWzHHdueHvA6BbwuRlTgGipdQ+3eVdo7WIF+g?= =?us-ascii?Q?1MCU2mVcNQnss+cEor3p6EpMMeMfSN4PjGcXFIY17X3PfwpsbE2NB+zQ9Dt2?= =?us-ascii?Q?HuheNqYxUhHEqf0Tun+96TseAa1aUFPcDAlP7u+enAyRlps1+b1BpKhQZrpE?= =?us-ascii?Q?AaO1zYNJLUWGEgceoX8A9ab97DLkSoFbSEwges07saVTMr0RF6ZIRWgjBzXg?= =?us-ascii?Q?tP655jkyzIYVFbEcXduylWD4axXbX2EwoozAD8JFkBEIsRSqd3aT5h4AHcxY?= =?us-ascii?Q?hUr9FFyeZPU3b7EdEG1oTKHH1MC84dCVyKKRpajrNiZSL6n+W3aY+Y0aAoN3?= =?us-ascii?Q?Pv+uvSuzvtB2D7zBpVPBnESDBHe9GZP+eYJw2DgW79a4NPdPm3c3sDwrSRvd?= =?us-ascii?Q?1PTKLbTNpY7gKS9OjERHlIULD7aTL/cHWHPD6BFhXw4QnH0U9M4rh92hp4w1?= =?us-ascii?Q?FZjBU3hi3uhLZOI+kXMLs71+FPkhscPCnEjpZPPTG2D/6SI31hcGM1RC1PaI?= =?us-ascii?Q?HOvpKWkE108h/Ipvq1HrYh7pDiC4zdjLnVWP1g2ASjWXgANNdSZaxpiQQnq0?= =?us-ascii?Q?nTx/fQ/XHlFqsg4IzLEywg6LlbuumImBu4Oox/YU/sGiae2xlMeLZ2DMSjBQ?= =?us-ascii?Q?LvU0La0eY42BMpOE6pJe5SG3RI2CC1uOQlvWwYHWVk1Bl5YQmGZMy4stfw3P?= =?us-ascii?Q?p5cgTkhqy2I6tc14QJ5sH3Zl5JTCM+NA16WCTjevLpiOmdHq5kieo9UPjUtW?= =?us-ascii?Q?uhh2+AyeNFvngXDf/Nos4YXjfwaiJmSiLJ9RIZTLuLgR1FuliqC7HJGB+KN9?= =?us-ascii?Q?fhL0FSUYlUlvcBBEQSNIFrJJ3av/lYzG8r/0pVF4MaB7lspB5iIbL2C6x+OC?= =?us-ascii?Q?FvRXIKPAs45j8EZhqcuHzeFbK3LQBdDXUNL5U3me?= 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: 8ca72bcb-12f3-4b3d-2633-08db513033df X-MS-Exchange-CrossTenant-originalarrivaltime: 10 May 2023 08:26:07.3253 (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: jDaZ7XotbICwUNRIlFS8seDXnKYZhSewW628RKssAhljvkz9VUP8uyKyfIam/O/vFbESxGXbhXa9Z40VFufH0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4359 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, May 10, 2023 4:24 PM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Igor Kulchytskyy > > Subject: [edk2-redfish-client][PATCH 3/4] RedfishClientPkg: Update > RedfishLib >=20 > Caution: This message originated from an External Source. Use proper > caution when opening attachments, clicking links, or responding. >=20 >=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: Igor Kulchytskyy > --- > .../edk2libredfish/include/redfishPayload.h | 31 +- > .../edk2libredfish/include/redfishService.h | 33 +- > .../PrivateLibrary/RedfishLib/RedfishLib.c | 12 +- > .../RedfishLib/edk2libredfish/src/payload.c | 107 +++- > .../RedfishLib/edk2libredfish/src/service.c | 575 +++++++++++++++++- > 5 files changed, 749 insertions(+), 9 deletions(-) >=20 > diff --git > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= sh > Payload.h > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= sh > Payload.h > index 44515306..8403d693 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 > @@ -65,6 +65,15 @@ patchPayload ( > EFI_HTTP_STATUS_CODE **StatusCode > ); >=20 > +redfishPayload * > +patchPayloadEx ( > + redfishPayload *target, > + redfishPayload *payload, > + EFI_HTTP_HEADER **Headers, > + UINTN *HeaderCount, > + EFI_HTTP_STATUS_CODE **StatusCode > + ); > + > redfishPayload * > postContentToPayload ( > redfishPayload *target, > @@ -74,6 +83,17 @@ postContentToPayload ( > EFI_HTTP_STATUS_CODE **StatusCode > ); >=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 > + ); > + > redfishPayload * > postPayload ( > redfishPayload *target, > @@ -81,6 +101,15 @@ postPayload ( > EFI_HTTP_STATUS_CODE **StatusCode > ); >=20 > +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= sh > Service.h > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfi= sh > Service.h > index 5c13b682..c41c0d14 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 > @@ -104,6 +104,15 @@ getUriFromService ( > EFI_HTTP_STATUS_CODE **StatusCode > ); >=20 > +json_t * > +getUriFromServiceEx ( > + redfishService *service, > + const char *uri, > + EFI_HTTP_HEADER **Headers, > + UINTN *HeaderCount, > + EFI_HTTP_STATUS_CODE **StatusCode > + ); > + > json_t * > patchUriFromService ( > redfishService *service, > @@ -112,6 +121,16 @@ patchUriFromService ( > EFI_HTTP_STATUS_CODE **StatusCode > ); >=20 > +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, > @@ -122,6 +141,18 @@ postUriFromService ( > EFI_HTTP_STATUS_CODE **StatusCode > ); >=20 > +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, > diff --git a/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.c > b/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.c > index 9f9d3779..2050d3b2 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 > @@ -331,7 +331,7 @@ RedfishGetByUri ( >=20 > ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); >=20 > - JsonValue =3D getUriFromService (RedfishService, Uri, &RedR= esponse- > >StatusCode); > + JsonValue =3D getUriFromServiceEx (RedfishService, Uri, > &RedResponse->Headers, &RedResponse->HeaderCount, &RedResponse- > >StatusCode); > RedResponse->Payload =3D createRedfishPayload (JsonValue, > RedfishService); >=20 > // > @@ -556,9 +556,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 > @@ -624,9 +626,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/src/payload.c > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c > index 7ceb63ac..8ec2ed4a 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 > @@ -379,6 +379,45 @@ getPayloadForPathString ( > 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 > + 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, > @@ -416,6 +455,44 @@ patchPayload ( > 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, > @@ -452,6 +529,34 @@ postContentToPayload ( > 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),= NULL, > Headers, HeaderCount, StatusCode); > + free (content); > + return ret; > +} > + > redfishPayload * > postPayload ( > redfishPayload *target, > diff --git > a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c > b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c > index 969aa5a0..9bcbfa10 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 > @@ -401,6 +401,199 @@ 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= ) || > (HeaderCount =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, > @@ -558,10 +751,12 @@ ON_EXIT: > } >=20 > json_t * > -patchUriFromService ( > +patchUriFromServiceEx ( > redfishService *service, > const char *uri, > const char *content, > + EFI_HTTP_HEADER **Headers, > + UINTN *HeaderCount, > EFI_HTTP_STATUS_CODE **StatusCode > ) > { > @@ -701,6 +896,10 @@ patchUriFromService ( > **StatusCode =3D ResponseMsg.Data.Response->StatusCode; > } >=20 > + if (ResponseMsg.Headers !=3D NULL) { > + *Headers =3D cloneHttpHeaders (&ResponseMsg, HeaderCount); } > + > if (EncodedContent !=3D content) { > FreePool (EncodedContent); > } > @@ -736,6 +935,378 @@ 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= ) || (StatusCode > =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= ) || (StatusCode > =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 > (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; > +} > + > json_t * > postUriFromService ( > redfishService *service, > -- > 2.17.1