]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg:Add a new error status code EFI_HTTP_ERROR
authorZhang Lubo <lubo.zhang@intel.com>
Fri, 29 Jan 2016 03:17:34 +0000 (11:17 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Wed, 3 Feb 2016 03:48:36 +0000 (11:48 +0800)
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 <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
NetworkPkg/HttpBootDxe/HttpBootClient.c
NetworkPkg/HttpBootDxe/HttpBootSupport.c
NetworkPkg/HttpBootDxe/HttpBootSupport.h
NetworkPkg/HttpDxe/HttpImpl.c
NetworkPkg/HttpDxe/HttpImpl.h
NetworkPkg/HttpDxe/HttpProto.h

index f0817e92e21e38b3d7ef4ccf606947ce2efbf605..dd835c4f833a75e64dfe860c070e0fffa50f099c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of the boot file download function.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -717,6 +717,7 @@ HttpBootGetBootFile (
   )\r
 {\r
   EFI_STATUS                 Status;\r
+  EFI_HTTP_STATUS_CODE       StatusCode;\r
   CHAR8                      *HostName;\r
   EFI_HTTP_REQUEST_DATA      *RequestData;\r
   HTTP_IO_RESPONSE_DATA      *ResponseData;\r
@@ -894,7 +895,12 @@ HttpBootGetBootFile (
              TRUE,\r
              ResponseData\r
              );\r
-  if (EFI_ERROR (Status)) {\r
+  if (EFI_ERROR (Status) || EFI_ERROR (ResponseData->Status)) {\r
+    if (EFI_ERROR (ResponseData->Status)) {\r
+      StatusCode = HttpIo->RspToken.Message->Data.Response->StatusCode;\r
+      HttpBootPrintErrorMessage (StatusCode);\r
+      Status = ResponseData->Status;\r
+    }\r
     goto ERROR_5;\r
   }\r
 \r
index f9bbe4b1a0e7ddf8d97666f24ab6802118af929e..db2af780a10a6d00895f9b6acaa9ac3bce0321b4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Support functions implementation for UEFI HTTP boot driver.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -930,7 +930,6 @@ HttpIoRecvResponse (
 {\r
   EFI_STATUS                 Status;\r
   EFI_HTTP_PROTOCOL          *Http;\r
-  EFI_HTTP_STATUS_CODE       StatusCode;\r
 \r
   if (HttpIo == NULL || HttpIo->Http == NULL || ResponseData == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -971,17 +970,10 @@ HttpIoRecvResponse (
   //\r
   // Store the received data into the wrapper.\r
   //\r
-  Status = HttpIo->RspToken.Status;\r
-  if (!EFI_ERROR (Status)) {\r
-    ResponseData->HeaderCount = HttpIo->RspToken.Message->HeaderCount;\r
-    ResponseData->Headers     = HttpIo->RspToken.Message->Headers;\r
-    ResponseData->BodyLength  = HttpIo->RspToken.Message->BodyLength;\r
-  }\r
-  \r
-  if (RecvMsgHeader) {\r
-    StatusCode = HttpIo->RspToken.Message->Data.Response->StatusCode;\r
-    HttpBootPrintErrorMessage (StatusCode);\r
-  }\r
+  ResponseData->Status = HttpIo->RspToken.Status;\r
+  ResponseData->HeaderCount = HttpIo->RspToken.Message->HeaderCount;\r
+  ResponseData->Headers     = HttpIo->RspToken.Message->Headers;\r
+  ResponseData->BodyLength  = HttpIo->RspToken.Message->BodyLength;\r
 \r
   return Status;\r
 }\r
index 2eba14e0267ff8f699a77307c47764a258f4e487..8e0fc37fdd8fe5b8cccb615db64f5471bb8def50 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Support functions declaration for UEFI HTTP boot driver.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -81,6 +81,17 @@ HttpBootShowIp6Addr (
   IN EFI_IPv6_ADDRESS   *Ip\r
   );\r
 \r
+/**\r
+  This function is to display the HTTP error status.\r
+\r
+  @param[in]      StatusCode      The status code value in HTTP message.\r
+\r
+**/\r
+VOID\r
+HttpBootPrintErrorMessage (\r
+  EFI_HTTP_STATUS_CODE            StatusCode\r
+  );\r
+\r
 //\r
 // A wrapper structure to hold the HTTP headers.\r
 //\r
@@ -196,6 +207,7 @@ typedef struct {
   EFI_HTTP_HEADER             *Headers;\r
   UINTN                       BodyLength;\r
   CHAR8                       *Body;\r
+  EFI_STATUS                  Status;\r
 } HTTP_IO_RESPONSE_DATA;\r
 \r
 /**\r
index b46f0ae3caef3a848ae5f0259cc72a1de1f54deb..a068cfb76b4af7b57fa741b2cdde767750f53738 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of EFI_HTTP_PROTOCOL protocol interfaces.\r
 \r
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 \r
   This program and the accompanying materials\r
@@ -976,7 +976,7 @@ HttpResponseWorker (
     HttpHeaders = NULL;\r
     \r
     HttpMsg->Data.Response->StatusCode = HttpMappingToStatusCode (StatusCode);\r
-\r
+    HttpInstance->StatusCode = StatusCode;\r
     //\r
     // Init message-body parser by header information.  \r
     //\r
@@ -1111,7 +1111,13 @@ Exit:
   if (Item != NULL) {\r
     NetMapRemoveItem (&Wrap->HttpInstance->RxTokens, Item, NULL);\r
   }\r
-  Token->Status = Status;\r
+\r
+  if (HttpInstance->StatusCode >= HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE) {\r
+    Token->Status = EFI_HTTP_ERROR;\r
+  } else {\r
+    Token->Status = Status;\r
+  }\r
+\r
   gBS->SignalEvent (Token->Event);\r
   HttpCloseTcpRxEvent (Wrap);\r
   FreePool (Wrap);\r
@@ -1136,7 +1142,12 @@ Error:
     HttpInstance->CacheBody = NULL;\r
   }\r
 \r
-  Token->Status = Status;\r
+  if (HttpInstance->StatusCode >= HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE) {\r
+    Token->Status = EFI_HTTP_ERROR;\r
+  } else {\r
+    Token->Status = Status;\r
+  }\r
+\r
   gBS->SignalEvent (Token->Event);\r
 \r
   return Status;  \r
index bfbaeccef2b26be6dc0e871761eb2e74e2ceb3d1..38228425bb5092b3c39e5ee2164798aaecdc52e4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The header files of implementation of EFI_HTTP_PROTOCOL protocol interfaces.\r
 \r
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -23,6 +23,8 @@
 #define HTTP_VERSION_CRLF_STR    " HTTP/1.1\r\n"\r
 #define HTTP_GET_STR             "GET "\r
 #define HTTP_HEAD_STR            "HEAD "\r
+#define HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE         300\r
+\r
 //\r
 // Connect method has maximum length according to EFI_HTTP_METHOD defined in\r
 // UEFI2.5 spec so use this.\r
index e43a2dc01c54e669a9cd4c887117f8d61a8d7716..3a574949de24657e084fc8445b54b37eb131050b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The header files of miscellaneous routines for HttpDxe driver.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -90,6 +90,8 @@ typedef struct _HTTP_PROTOCOL {
   BOOLEAN                       InDestroy;\r
   INTN                          State;\r
 \r
+  UINTN                         StatusCode;\r
+\r
   EFI_HANDLE                    Tcp4ChildHandle;\r
   EFI_TCP4_PROTOCOL             *Tcp4;\r
   EFI_TCP4_CONFIG_DATA          Tcp4CfgData;\r