Reviewed-by: Jiaxin Wu <jiaxin...@intel.com>
-----Original Message----- From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Zhang Lubo Sent: Wednesday, January 27, 2016 3:28 PM To: edk2-devel@lists.01.org Cc: Ye, Ting; Fu, Siyuan; Wu, Jiaxin Subject: [edk2] [patch 2/2] NetworkPkg:Add a new error status code EFI_HTTP_ERROR Add a new error status code EFI_HTTP_ERROR in corresponding with the UEFI 2.6 spec, when EFI_HTTP_PROTOCOL.Response() is called and the protocol interface encounter a HTTP error, it should return the new error status to the caller. Cc: Fu Siyuan <siyuan...@intel.com> Cc: Ye Ting <ting...@intel.com> Cc: Wu Jiaxin <jiaxin...@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo <lubo.zh...@intel.com> --- NetworkPkg/HttpBootDxe/HttpBootSupport.c | 4 +--- NetworkPkg/HttpDxe/HttpImpl.c | 10 +++++++++- NetworkPkg/HttpDxe/HttpImpl.h | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c b/NetworkPkg/HttpBootDxe/HttpBootSupport.c index f9bbe4b..38743c6 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c +++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c @@ -974,13 +974,11 @@ HttpIoRecvResponse ( Status = HttpIo->RspToken.Status; if (!EFI_ERROR (Status)) { ResponseData->HeaderCount = HttpIo->RspToken.Message->HeaderCount; ResponseData->Headers = HttpIo->RspToken.Message->Headers; ResponseData->BodyLength = HttpIo->RspToken.Message->BodyLength; - } - - if (RecvMsgHeader) { + } else if (Status == EFI_HTTP_ERROR) { StatusCode = HttpIo->RspToken.Message->Data.Response->StatusCode; HttpBootPrintErrorMessage (StatusCode); } return Status; diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index aee3de5..3ea95b6 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -814,10 +814,12 @@ HttpBodyParserCallback ( @retval EFI_SUCCESS Allocation succeeded. @retval EFI_OUT_OF_RESOURCES Failed to complete the opration due to lack of resources. @retval EFI_NOT_READY Can't find a corresponding Tx4Token/Tx6Token or the EFI_HTTP_UTILITIES_PROTOCOL is not available. + @retval EFI_HTTP_ERROR A HTTP error occurred during the network operation. The response + status code is returned in Token->Message-> Response->StatusCode. **/ EFI_STATUS HttpResponseWorker ( IN HTTP_TOKEN_WRAP *Wrap @@ -973,12 +975,16 @@ HttpResponseWorker ( goto Error; } FreePool (HttpHeaders); HttpHeaders = NULL; - + HttpMsg->Data.Response->StatusCode = HttpMappingToStatusCode (StatusCode); + if (StatusCode >= HTTP_ERROR_STATUS) { + Status = EFI_HTTP_ERROR; + goto Error; + } // // Init message-body parser by header information. // Status = EFI_NOT_READY; @@ -1189,10 +1195,12 @@ Error: Token->Message->Data is NULL, but a previous call to Response() has not been completed successfully. @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources. @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host specified by response URL. + @retval EFI_HTTP_ERROR A HTTP error occurred during the network operation. The response + status code is returned in Token->Message-> Response->StatusCode. **/ EFI_STATUS EFIAPI EfiHttpResponse ( IN EFI_HTTP_PROTOCOL *This, diff --git a/NetworkPkg/HttpDxe/HttpImpl.h b/NetworkPkg/HttpDxe/HttpImpl.h index afbe982..5c159fc 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.h +++ b/NetworkPkg/HttpDxe/HttpImpl.h @@ -14,10 +14,11 @@ **/ #ifndef __EFI_HTTP_IMPL_H__ #define __EFI_HTTP_IMPL_H__ +#define HTTP_ERROR_STATUS 300 #define HTTP_DEFAULT_PORT 80 #define HTTP_END_OF_HDR_STR "\r\n\r\n" #define HTTP_CRLF_STR "\r\n" #define HTTP_VERSION_STR "HTTP/1.1" #define HTTP_VERSION_CRLF_STR " HTTP/1.1\r\n" -- 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel