diff options
author | Andreas Kling <kling@serenityos.org> | 2022-03-08 17:44:22 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-09 16:43:00 +0100 |
commit | 252ed8ad18c6d1a880eebd5dcd98b6984e4aa8ff (patch) | |
tree | 28476f00ad44bdeecd44d34adfce17e4a40c1458 /Userland/Libraries/LibWeb | |
parent | 7b3642d08c11db7b02f205a8b649b5ffcc609bf2 (diff) | |
download | serenity-252ed8ad18c6d1a880eebd5dcd98b6984e4aa8ff.zip |
LibWeb: Fail resource loads on HTTP 4xx or 5xx error
This fixes an issue on ACID3 where failing image loads with body content
would still get displayed.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp index 09e2e4bed7..9515005d60 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -221,11 +221,15 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, con --m_pending_loads; if (on_load_counter_change) on_load_counter_change(); - if (!success) { - auto http_load_failure_msg = "HTTP load failed"sv; - log_failure(request, http_load_failure_msg); + if (!success || (status_code.has_value() && *status_code >= 400 && *status_code <= 599)) { + StringBuilder error_builder; + if (status_code.has_value()) + error_builder.appendff("Load failed: {}", *status_code); + else + error_builder.append("Load failed"); + log_failure(request, error_builder.string_view()); if (error_callback) - error_callback(http_load_failure_msg, {}); + error_callback(error_builder.to_string(), {}); return; } log_success(request); |