From nobody Thu May 16 07:47:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+108778+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695042818558426.77872454937653; Mon, 18 Sep 2023 06:13:38 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=zIMZLvy9SSJQ5Ei4B/+01hnUOcKHoILag2+nC6X4yeM=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1695042818; v=1; b=aEwOXNkPOron0Pw0TcabBoE5MkX3AW8lQCjh6fl+q6XitrZRvCj+zEU/2e/JPqmH2mfGLdz8 y0HQpFI6m+iBLkUAvSgIypGE/drna7R53wa1UZS7hHX4eDH16dhM446hlcNXEdgclQKl41Jpxkg Z997ibsmaAOecZk1SfSIZDro= X-Received: by 127.0.0.2 with SMTP id urewYY1788612xDGrczR0N5C; Mon, 18 Sep 2023 06:13:38 -0700 X-Received: from NAM02-BN1-obe.outbound.protection.outlook.com (NAM02-BN1-obe.outbound.protection.outlook.com [40.107.212.62]) by mx.groups.io with SMTP id smtpd.web11.50880.1695042817211622007 for ; Mon, 18 Sep 2023 06:13:37 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JDDkLR+s/HhQgpKTw8iEtBdzSbKlJO97f5ovirO8EIZlZMiend7EnZbH2BUawf8SQCE6CavHt2qUhwkz5Eyhso7+Y/kP8D9iPE2y20DJPY1jvVQ1xplpxhxes2dalRqNwGyiSHKDQU6cIfqrT3o7CCnTaUqiLDL1G6n+Arvgl8u1LnXEEG/rhQlJFkcrDEPUkpV/kS5IoU4IqPPqDswEuxWyNOEottoBL0fAwon4YYXWNGw9iaCrLTnWOGlxWqV3kZhEUODOjtNZY14aJ7Dt2UVH8k1/cANZleg82Si6x2R3sKL3NY9Mgb+nznb2aRW4/9RKfzP9N09v2+pdCZbntw== 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=ql/h4K3SgyX59hHrU11jqmnYxeYT02/89KlvSQSMce0=; b=deF5YMHIm6VKNL+mz7Uoxz0yW1vqkqEQlGFpVvLwY9K8tMaI9dIGunFyBPoGFZbAUxDCcEhf4JSArzuySLV7t1ynQdW+D5rSqAr8udMS4MV5RzxHl7hXGd9i7U/J9sXx9ndXCFnBA2pUuWoBGcRRnAyHRex9uWAyEjFc2zRd6yGw2lf4Dt1Ll5LPAMSGAw76JOJrzSpBo2aBt9+t1d2VVXKkZPqXP4Nae3hrnEdoVIVpd0a0VgKkLf19YqY+S/XA5XObDUqIgxoXzhx4rG7ohFw+tARFr2dAcgIShMGS5/bmCQIt7NKeBNThkGJxp1IsWurcxYh2GRKTtRD0TmgDHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none X-Received: from MW4PR03CA0050.namprd03.prod.outlook.com (2603:10b6:303:8e::25) by SN7PR12MB8434.namprd12.prod.outlook.com (2603:10b6:806:2e6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Mon, 18 Sep 2023 13:13:34 +0000 X-Received: from MWH0EPF000989EB.namprd02.prod.outlook.com (2603:10b6:303:8e:cafe::f3) by MW4PR03CA0050.outlook.office365.com (2603:10b6:303:8e::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 13:13:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+108778+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.118.233) by MWH0EPF000989EB.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20 via Frontend Transport; Mon, 18 Sep 2023 13:13:34 +0000 X-Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 18 Sep 2023 06:13:24 -0700 X-Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 18 Sep 2023 06:13:23 -0700 X-Received: from NV-CL38DL3.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Mon, 18 Sep 2023 06:13:22 -0700 From: "Nickle Wang via groups.io" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" , Mike Maslenkin Subject: [edk2-devel] [PATCH v2] RedfishPkg/RedfishRestExDxe: return HTTP status code to caller. Date: Mon, 18 Sep 2023 21:13:22 +0800 Message-ID: <20230918131322.7761-1-nicklew@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EB:EE_|SN7PR12MB8434:EE_ X-MS-Office365-Filtering-Correlation-Id: ac09e84f-ba35-46a0-9125-08dbb8490ffa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: BrGOh/fTE05voqcjr+imy0Vx0OZIKzCEi0WzuFYTldfwNdRyMbvTAh0ub9yocCG4lWeFkAdHFVR3gAk6nWOnLDJaxzXrt6zikEiqxossczdmSyn1S36/oa1hfMB0bjx2PT3wUfyJ5BTqmkwQET01rX0HO0NIdG2vVOKX3FYlBlyOyUVlp0U4B+dM0ONOMeb213Sb9GDAA79fy1N+6XMHcZwZuheqFEGUXVa+n4UKlrxQF4eSLZp82VHoNg523l7x44RhjC8Mkoobl5QN9/TTaCbg82PKvgR91+zPegKlUjWij9Y3Ht6JF/EELDrLM7dV9sgPfbyX9VYgxCkgTg6myzkFNdVj9/x+WFdGqmxUcT6/LWNqHWY4CymOrRxrIkOR02kz9Awc9C/OsLojGr856CRBK5Tv3soDedtzPMnhgvw79f5HIks4/GK1UK9gdA7WtKY9ig4gSO18usGHGH1bxVffBVMfHWJysmRhC4HsnLQ/axX76m2L99shObxFC2nxAjq0iANpf7CfH9jKHkOJo76sRm3jFm2MHywGEgJq+5AhRY7P6CwZYXWTMFcqBDHEZaw03tuHHkND1JnICMH2i8jyMgPZw2CD+yrnbiYIkkwN8UURXqTH5hJGAZlR/QPYebOj0GyNe2prd4cWRggVCqTqWPD46/NzvGgqiT5LAFz2zg0jgXXpgfx4IYn3kHQCeRHiaLt1famRVPI4VFDlO2n1fbhmTNrxVzhjbHCY6BvzmUZY9ILFq2PVGukhebDI X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 13:13:34.2478 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac09e84f-ba35-46a0-9125-08dbb8490ffa X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8434 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,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: R342YqMJISUipbjRd9kGPOTYx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1695042819268100001 Content-Type: text/plain; charset="utf-8" Return unsupported HTTP status code to caller so caller can handle HTTP error status code. Current implementation only return EFI error to caller. Without knowing the HTTP status code, caller has trouble to handle HTTP request failure. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez Cc: Mike Maslenkin Reviewed-by: Abner Chang Reviewed-by: Igor Kulchytskyy --- MdePkg/Include/Protocol/RestEx.h | 3 ++- .../RedfishRestExDxe/RedfishRestExProtocol.c | 27 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/MdePkg/Include/Protocol/RestEx.h b/MdePkg/Include/Protocol/Res= tEx.h index e9bc7be94f2c..da9f1c3f87ef 100644 --- a/MdePkg/Include/Protocol/RestEx.h +++ b/MdePkg/Include/Protocol/RestEx.h @@ -131,7 +131,8 @@ typedef struct { response when the data is retrieved from the service. RequestMessage con= tains the HTTP request to the REST resource identified by RequestMessage.Request.Url. T= he ResponseMessage is the returned HTTP response for that request, includin= g any HTTP - status. + status. It's caller's responsibility to free this ResponseMessage using = FreePool(). + RestConfigFreeHttpMessage() in RedfishLib is an example to release Respo= nseMessage structure. =20 @param[in] This Pointer to EFI_REST_EX_PROTOCOL instance= for a particular REST service. diff --git a/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c b/RedfishP= kg/RedfishRestExDxe/RedfishRestExProtocol.c index 90973619f2bc..5bcdade4b18c 100644 --- a/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c +++ b/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c @@ -29,7 +29,8 @@ EFI_REST_EX_PROTOCOL mRedfishRestExProtocol =3D { response when the data is retrieved from the service. RequestMessage con= tains the HTTP request to the REST resource identified by RequestMessage.Request.Url. T= he ResponseMessage is the returned HTTP response for that request, includin= g any HTTP - status. + status. It's caller's responsibility to free this ResponseMessage using = FreePool(). + RestConfigFreeHttpMessage() in RedfishLib is an example to release Respo= nseMessage structure. =20 @param[in] This Pointer to EFI_REST_EX_PROTOCOL instance= for a particular REST service. @@ -320,6 +321,18 @@ ReSendRequest:; DEBUG ((DEBUG_ERROR, "This HTTP Status is not handled!\n")); DumpHttpStatusCode (DEBUG_REDFISH_NETWORK, ResponseData->Response.Stat= usCode); Status =3D EFI_UNSUPPORTED; + + // + // Deliver status code back to caller so caller can handle it. + // + ResponseMessage->Data.Response =3D AllocateZeroPool (sizeof (EFI_HTTP_= RESPONSE_DATA)); + if (ResponseMessage->Data.Response =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto ON_EXIT; + } + + ResponseMessage->Data.Response->StatusCode =3D ResponseData->Response.= StatusCode; + goto ON_EXIT; } =20 @@ -443,18 +456,6 @@ ON_EXIT: FreePool (ResponseData); } =20 - if (EFI_ERROR (Status)) { - if (ResponseMessage->Data.Response !=3D NULL) { - FreePool (ResponseMessage->Data.Response); - ResponseMessage->Data.Response =3D NULL; - } - - if (ResponseMessage->Body !=3D NULL) { - FreePool (ResponseMessage->Body); - ResponseMessage->Body =3D NULL; - } - } - return Status; } =20 --=20 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 (#108778): https://edk2.groups.io/g/devel/message/108778 Mute This Topic: https://groups.io/mt/101432753/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-