summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/HttpBootDxe/HttpBootSupport.c
diff options
context:
space:
mode:
authorFu Siyuan <siyuan.fu@intel.com>2017-07-26 15:57:38 +0800
committerFu Siyuan <siyuan.fu@intel.com>2017-08-03 14:12:43 +0800
commitbb4831c03dd15ff8528dcdbc7d2ad1835f55563e (patch)
tree343482b29459ea663d2f29c526531b9fadaac964 /NetworkPkg/HttpBootDxe/HttpBootSupport.c
parentf11a7a555269f469b609ceb77221b59ec9b93ba9 (diff)
downloadedk2-bb4831c03dd15ff8528dcdbc7d2ad1835f55563e.tar.gz
edk2-bb4831c03dd15ff8528dcdbc7d2ad1835f55563e.tar.bz2
edk2-bb4831c03dd15ff8528dcdbc7d2ad1835f55563e.zip
NetworkPkg: Display HTTP redirection info to the screen if need.
HTTP defines a set of status code for redirecting a request to a different URI in Section 6.4 of RFC7231 and also RFC7583. This patch updates the HTTP boot driver to display the redirection info to the screen so the user would have chance to know new URI address of the HTTP boot image. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Diffstat (limited to 'NetworkPkg/HttpBootDxe/HttpBootSupport.c')
-rw-r--r--NetworkPkg/HttpBootDxe/HttpBootSupport.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
index a19fe6cdbf..4e78cf3b96 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
@@ -1034,7 +1034,8 @@ HttpIoRecvResponse (
HttpIo->IsRxDone = FALSE;
}
- if (!EFI_ERROR (HttpIo->RspToken.Status) && HttpIo->Callback != NULL) {
+ if ((HttpIo->Callback != NULL) &&
+ (HttpIo->RspToken.Status == EFI_SUCCESS || HttpIo->RspToken.Status == EFI_HTTP_ERROR)) {
Status = HttpIo->Callback (
HttpIoResponse,
HttpIo->RspToken.Message,
@@ -1319,3 +1320,25 @@ HttpBootRegisterRamDisk (
return Status;
}
+/**
+ Indicate if the HTTP status code indicates a redirection.
+
+ @param[in] StatusCode HTTP status code from server.
+
+ @return TRUE if it's redirection.
+
+**/
+BOOLEAN
+HttpBootIsHttpRedirectStatusCode (
+ IN EFI_HTTP_STATUS_CODE StatusCode
+ )
+{
+ if (StatusCode == HTTP_STATUS_301_MOVED_PERMANENTLY ||
+ StatusCode == HTTP_STATUS_302_FOUND ||
+ StatusCode == HTTP_STATUS_307_TEMPORARY_REDIRECT ||
+ StatusCode == HTTP_STATUS_308_PERMANENT_REDIRECT) {
+ return TRUE;
+ }
+
+ return FALSE;
+}