LibWeb: Add basic support for redirects

This commit is contained in:
Linus Groh 2020-05-03 22:58:33 +01:00 committed by Andreas Kling
parent e09b83c60c
commit 94c28552c6
Notes: sideshowbarker 2024-07-19 07:00:21 +09:00

View file

@ -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;