From 94c28552c6e29cebd83bf48084262c1003f7baab Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 3 May 2020 22:58:33 +0100 Subject: [PATCH] LibWeb: Add basic support for redirects --- Libraries/LibWeb/HtmlView.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Libraries/LibWeb/HtmlView.cpp b/Libraries/LibWeb/HtmlView.cpp index 0a1cb337ad..63753203c5 100644 --- a/Libraries/LibWeb/HtmlView.cpp +++ b/Libraries/LibWeb/HtmlView.cpp @@ -27,11 +27,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -370,6 +370,13 @@ void HtmlView::load(const URL& url) ResourceLoader::the().load( url, [this, url](auto data, auto& response_headers) { + // FIXME: Also check HTTP status code before redirecting + auto location = response_headers.get("Location"); + if (location.has_value()) { + load(location.value()); + return; + } + if (data.is_null()) { load_error_page(url, "No data"); return;