]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Report Http Errors to screen when http layer occurs an error
authorZhang Lubo <lubo.zhang@intel.com>
Tue, 10 Nov 2015 02:18:31 +0000 (02:18 +0000)
committerluobozhang <luobozhang@Edk2>
Tue, 10 Nov 2015 02:18:31 +0000 (02:18 +0000)
Http server will return error status in http header when http connection
cannot be established,so the http boot driver should print the error code
code to the screen and the users can know what happened.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18761 6f19259b-4bc3-4df7-8a09-765794883524

NetworkPkg/HttpBootDxe/HttpBootSupport.c

index d08111f66107e84efceab75e9554ed45821c7259..1fc4e768806cc31b126cdc984683682c96b56d01 100644 (file)
@@ -146,6 +146,149 @@ HttpBootShowIp6Addr (
   }\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
+  AsciiPrint ("\n");\r
+\r
+  switch (StatusCode) {\r
+  case HTTP_STATUS_300_MULTIPLE_CHIOCES:\r
+    AsciiPrint ("\n  Redirection: 300 Multiple Choices");\r
+    break; \r
+    \r
+  case HTTP_STATUS_301_MOVED_PERMANENTLY:\r
+    AsciiPrint ("\n  Redirection: 301 Moved Permanently");\r
+    break; \r
+    \r
+  case HTTP_STATUS_302_FOUND:\r
+    AsciiPrint ("\n  Redirection: 302 Found");\r
+    break; \r
+    \r
+  case HTTP_STATUS_303_SEE_OTHER:\r
+    AsciiPrint ("\n  Redirection: 303 See Other");\r
+    break; \r
+\r
+  case HTTP_STATUS_304_NOT_MODIFIED:\r
+    AsciiPrint ("\n  Redirection: 304 Not Modified");\r
+    break; \r
+\r
+  case HTTP_STATUS_305_USE_PROXY:\r
+    AsciiPrint ("\n  Redirection: 305 Use Proxy");\r
+    break; \r
+\r
+  case HTTP_STATUS_307_TEMPORARY_REDIRECT:\r
+    AsciiPrint ("\n  Redirection: 307 Temporary Redirect");\r
+    break; \r
+\r
+  case HTTP_STATUS_400_BAD_REQUEST:\r
+    AsciiPrint ("\n  Client Error: 400 Bad Request");\r
+    break;\r
+    \r
+  case HTTP_STATUS_401_UNAUTHORIZED:\r
+    AsciiPrint ("\n  Client Error: 401 Unauthorized");\r
+    break;\r
+    \r
+  case HTTP_STATUS_402_PAYMENT_REQUIRED:\r
+    AsciiPrint ("\n  Client Error: 402 Payment Required");\r
+    break;\r
+\r
+  case HTTP_STATUS_403_FORBIDDEN:\r
+    AsciiPrint ("\n  Client Error: 403 Forbidden");\r
+    break;\r
+\r
+  case HTTP_STATUS_404_NOT_FOUND:\r
+    AsciiPrint ("\n  Client Error: 404 Not Found");\r
+    break;\r
+\r
+  case HTTP_STATUS_405_METHOD_NOT_ALLOWED:\r
+    AsciiPrint ("\n  Client Error: 405 Method Not Allowed");\r
+    break;\r
+\r
+  case HTTP_STATUS_406_NOT_ACCEPTABLE:\r
+    AsciiPrint ("\n  Client Error: 406 Not Acceptable");\r
+    break;\r
+\r
+  case HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED:\r
+    AsciiPrint ("\n  Client Error: 407 Proxy Authentication Required");\r
+    break;\r
+\r
+  case HTTP_STATUS_408_REQUEST_TIME_OUT:\r
+    AsciiPrint ("\n  Client Error: 408 Request Timeout");\r
+    break;\r
+\r
+  case HTTP_STATUS_409_CONFLICT:\r
+    AsciiPrint ("\n  Client Error: 409 Conflict");\r
+    break;\r
+\r
+  case HTTP_STATUS_410_GONE:\r
+    AsciiPrint ("\n  Client Error: 410 Gone");\r
+    break;\r
+\r
+  case HTTP_STATUS_411_LENGTH_REQUIRED:\r
+    AsciiPrint ("\n  Client Error: 411 Length Required");\r
+    break;\r
+\r
+  case HTTP_STATUS_412_PRECONDITION_FAILED:\r
+    AsciiPrint ("\n  Client Error: 412 Precondition Failed");\r
+    break;\r
+\r
+  case HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE:\r
+    AsciiPrint ("\n  Client Error: 413 Request Entity Too Large");\r
+    break;\r
+\r
+  case HTTP_STATUS_414_REQUEST_URI_TOO_LARGE:\r
+    AsciiPrint ("\n  Client Error: 414 Request URI Too Long");\r
+    break;\r
+\r
+  case HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE:\r
+    AsciiPrint ("\n  Client Error: 415 Unsupported Media Type");\r
+    break;\r
+\r
+  case HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED:\r
+    AsciiPrint ("\n  Client Error: 416 Requested Range Not Satisfiable");\r
+    break;\r
+\r
+  case HTTP_STATUS_417_EXPECTATION_FAILED:\r
+    AsciiPrint ("\n  Client Error: 417 Expectation Failed");\r
+    break;\r
+\r
+  case HTTP_STATUS_500_INTERNAL_SERVER_ERROR:\r
+    AsciiPrint ("\n  Server Error: 500 Internal Server Error");\r
+    break;\r
+\r
+  case HTTP_STATUS_501_NOT_IMPLEMENTED:\r
+    AsciiPrint ("\n  Server Error: 501 Not Implemented");\r
+    break;\r
+\r
+  case HTTP_STATUS_502_BAD_GATEWAY:\r
+    AsciiPrint ("\n  Server Error: 502 Bad Gateway");\r
+    break;\r
+\r
+  case HTTP_STATUS_503_SERVICE_UNAVAILABLE:\r
+    AsciiPrint ("\n  Server Error: 503 Service Unavailable");\r
+    break;\r
+\r
+  case HTTP_STATUS_504_GATEWAY_TIME_OUT:\r
+    AsciiPrint ("\n  Server Error: 504 Gateway Timeout");\r
+    break;\r
+\r
+  case HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED:\r
+    AsciiPrint ("\n  Server Error: 505 HTTP Version Not Supported");\r
+    break;\r
+\r
+  default: ;\r
+  \r
+  }\r
+}\r
+\r
 /**\r
   Notify the callback function when an event is triggered.\r
 \r
@@ -787,6 +930,7 @@ 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
@@ -818,7 +962,7 @@ HttpIoRecvResponse (
   }\r
 \r
   //\r
-  // Poll the network until transmit finish.\r
+  // Poll the network until receive finish.\r
   //\r
   while (!HttpIo->IsRxDone) {\r
     Http->Poll (Http);\r
@@ -833,6 +977,11 @@ HttpIoRecvResponse (
     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
 \r
   return Status;\r
 }\r