]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/HttpBootDxe/HttpBootSupport.c
NetworkPkg: Fix some typos in Http boot driver.
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootSupport.c
index d08111f66107e84efceab75e9554ed45821c7259..f9bbe4b1a0e7ddf8d97666f24ab6802118af929e 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
@@ -771,7 +914,7 @@ HttpIoSendRequest (
                                 FALSE to continue receive the previous response message.\r
   @param[out]  ResponseData     Point to a wrapper of the received response data.\r
   \r
-  @retval EFI_SUCCESS            The HTTP resopnse is received.\r
+  @retval EFI_SUCCESS            The HTTP response is received.\r
   @retval EFI_INVALID_PARAMETER  One or more parameters are invalid.\r
   @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory.\r
   @retval EFI_DEVICE_ERROR       An unexpected network or system error occurred.\r
@@ -782,11 +925,12 @@ EFI_STATUS
 HttpIoRecvResponse (\r
   IN      HTTP_IO                  *HttpIo,\r
   IN      BOOLEAN                  RecvMsgHeader,\r
-     OUT  HTTP_IO_RESOPNSE_DATA    *ResponseData\r
+     OUT  HTTP_IO_RESPONSE_DATA    *ResponseData\r
   )\r
 {\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