summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-05-03 22:58:33 +0100
committerAndreas Kling <kling@serenityos.org>2020-05-04 00:01:31 +0200
commit94c28552c6e29cebd83bf48084262c1003f7baab (patch)
tree81f837ae2bfad12f76f509f73907a7d7bc77e737 /Libraries
parente09b83c60c77bef5fc7704dfe6f70df75462b62f (diff)
downloadserenity-94c28552c6e29cebd83bf48084262c1003f7baab.zip
LibWeb: Add basic support for redirects
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibWeb/HtmlView.cpp9
1 files changed, 8 insertions, 1 deletions
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 <AK/FileSystemPath.h>
#include <AK/URL.h>
#include <LibCore/File.h>
-#include <LibGfx/ImageDecoder.h>
#include <LibGUI/Application.h>
#include <LibGUI/Painter.h>
#include <LibGUI/ScrollBar.h>
#include <LibGUI/Window.h>
+#include <LibGfx/ImageDecoder.h>
#include <LibJS/Runtime/Value.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/ElementFactory.h>
@@ -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;