/** @file\r
The implementation of EFI_LOAD_FILE_PROTOCOL for UEFI HTTP boot.\r
\r
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<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
case HttpBootHttpResponse:\r
if (Data != NULL) {\r
HttpMessage = (EFI_HTTP_MESSAGE *) Data;\r
+ \r
+ if (HttpMessage->Data.Response != NULL) {\r
+ if (HttpBootIsHttpRedirectStatusCode (HttpMessage->Data.Response->StatusCode)) {\r
+ //\r
+ // Server indicates the resource has been redirected to a different URL\r
+ // according to the section 6.4 of RFC7231 and the RFC 7538.\r
+ // Display the redirect information on the screen.\r
+ //\r
+ HttpHeader = HttpFindHeader (\r
+ HttpMessage->HeaderCount,\r
+ HttpMessage->Headers,\r
+ HTTP_HEADER_LOCATION\r
+ );\r
+ if (HttpHeader != NULL) {\r
+ Print (L"\n HTTP ERROR: Resource Redirected.\n New Location: %a\n", HttpHeader->FieldValue);\r
+ }\r
+ }\r
+ }\r
+ \r
HttpHeader = HttpFindHeader (\r
HttpMessage->HeaderCount,\r
HttpMessage->Headers,\r
// We already know the file size, print in percentage format.\r
//\r
if (Private->ReceivedSize == 0) {\r
- Print (L" File Size: %lu\n", Private->FileSize);\r
+ Print (L" File Size: %lu Bytes\n", Private->FileSize);\r
}\r
Private->ReceivedSize += DataLength;\r
Percentage = (UINT32) DivU64x64Remainder (MultU64x32 (Private->ReceivedSize, 100), Private->FileSize, NULL);\r
HttpIo->IsRxDone = FALSE;\r
}\r
\r
- if (!EFI_ERROR (HttpIo->RspToken.Status) && HttpIo->Callback != NULL) {\r
+ if ((HttpIo->Callback != NULL) && \r
+ (HttpIo->RspToken.Status == EFI_SUCCESS || HttpIo->RspToken.Status == EFI_HTTP_ERROR)) {\r
Status = HttpIo->Callback (\r
HttpIoResponse,\r
HttpIo->RspToken.Message,\r
return Status;\r
}\r
\r
+/**\r
+ Indicate if the HTTP status code indicates a redirection.\r
+ \r
+ @param[in] StatusCode HTTP status code from server.\r
+\r
+ @return TRUE if it's redirection.\r
+\r
+**/\r
+BOOLEAN\r
+HttpBootIsHttpRedirectStatusCode (\r
+ IN EFI_HTTP_STATUS_CODE StatusCode\r
+ )\r
+{\r
+ if (StatusCode == HTTP_STATUS_301_MOVED_PERMANENTLY ||\r
+ StatusCode == HTTP_STATUS_302_FOUND ||\r
+ StatusCode == HTTP_STATUS_307_TEMPORARY_REDIRECT ||\r
+ StatusCode == HTTP_STATUS_308_PERMANENT_REDIRECT) {\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
IN VOID *Buffer,\r
IN HTTP_BOOT_IMAGE_TYPE ImageType\r
);\r
+\r
+/**\r
+ Indicate if the HTTP status code indicates a redirection.\r
+ \r
+ @param[in] StatusCode HTTP status code from server.\r
+\r
+ @return TRUE if it's redirection.\r
+\r
+**/\r
+BOOLEAN\r
+HttpBootIsHttpRedirectStatusCode (\r
+ IN EFI_HTTP_STATUS_CODE StatusCode\r
+ );\r
#endif\r