From 072289f45c7ac13e6f70ba4ad739e95086e5d2d2 Mon Sep 17 00:00:00 2001 From: Zhang Lubo Date: Fri, 29 Jan 2016 11:17:34 +0800 Subject: NetworkPkg:Add a new error status code EFI_HTTP_ERROR v4: * Update macro HTTP_ERROR_STATUS to HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE Update copyright year. When the Error Status of ResponseData returned from HttpIoRecvResponse function during the Http HEAD method, it should also return error status to Load file protocol. Add a new error status code EFI_HTTP_ERROR in corresponding with the UEFI 2.6 spec . When a HTTP error occurred during the network operation, The EFI_HTTP_ERROR is returned in token. Cc: Fu Siyuan Cc: Ye Ting Cc: Wu Jiaxin Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo Reviewed-by: Siyuan Fu Reviewed-by: Ye Ting Reviewed-by: Jiaxin Wu --- NetworkPkg/HttpDxe/HttpImpl.c | 19 +++++++++++++++---- NetworkPkg/HttpDxe/HttpImpl.h | 4 +++- NetworkPkg/HttpDxe/HttpProto.h | 4 +++- 3 files changed, 21 insertions(+), 6 deletions(-) (limited to 'NetworkPkg/HttpDxe') diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index b46f0ae3ca..a068cfb76b 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -1,7 +1,7 @@ /** @file Implementation of EFI_HTTP_PROTOCOL protocol interfaces. - Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
This program and the accompanying materials @@ -976,7 +976,7 @@ HttpResponseWorker ( HttpHeaders = NULL; HttpMsg->Data.Response->StatusCode = HttpMappingToStatusCode (StatusCode); - + HttpInstance->StatusCode = StatusCode; // // Init message-body parser by header information. // @@ -1111,7 +1111,13 @@ Exit: if (Item != NULL) { NetMapRemoveItem (&Wrap->HttpInstance->RxTokens, Item, NULL); } - Token->Status = Status; + + if (HttpInstance->StatusCode >= HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE) { + Token->Status = EFI_HTTP_ERROR; + } else { + Token->Status = Status; + } + gBS->SignalEvent (Token->Event); HttpCloseTcpRxEvent (Wrap); FreePool (Wrap); @@ -1136,7 +1142,12 @@ Error: HttpInstance->CacheBody = NULL; } - Token->Status = Status; + if (HttpInstance->StatusCode >= HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE) { + Token->Status = EFI_HTTP_ERROR; + } else { + Token->Status = Status; + } + gBS->SignalEvent (Token->Event); return Status; diff --git a/NetworkPkg/HttpDxe/HttpImpl.h b/NetworkPkg/HttpDxe/HttpImpl.h index bfbaeccef2..38228425bb 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.h +++ b/NetworkPkg/HttpDxe/HttpImpl.h @@ -1,7 +1,7 @@ /** @file The header files of implementation of EFI_HTTP_PROTOCOL protocol interfaces. - Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -23,6 +23,8 @@ #define HTTP_VERSION_CRLF_STR " HTTP/1.1\r\n" #define HTTP_GET_STR "GET " #define HTTP_HEAD_STR "HEAD " +#define HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE 300 + // // Connect method has maximum length according to EFI_HTTP_METHOD defined in // UEFI2.5 spec so use this. diff --git a/NetworkPkg/HttpDxe/HttpProto.h b/NetworkPkg/HttpDxe/HttpProto.h index e43a2dc01c..3a574949de 100644 --- a/NetworkPkg/HttpDxe/HttpProto.h +++ b/NetworkPkg/HttpDxe/HttpProto.h @@ -1,7 +1,7 @@ /** @file The header files of miscellaneous routines for HttpDxe driver. -Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -90,6 +90,8 @@ typedef struct _HTTP_PROTOCOL { BOOLEAN InDestroy; INTN State; + UINTN StatusCode; + EFI_HANDLE Tcp4ChildHandle; EFI_TCP4_PROTOCOL *Tcp4; EFI_TCP4_CONFIG_DATA Tcp4CfgData; -- cgit v1.2.3