summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-03-08 17:44:22 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-09 16:43:00 +0100
commit252ed8ad18c6d1a880eebd5dcd98b6984e4aa8ff (patch)
tree28476f00ad44bdeecd44d34adfce17e4a40c1458 /Userland/Libraries/LibWeb
parent7b3642d08c11db7b02f205a8b649b5ffcc609bf2 (diff)
downloadserenity-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.cpp12
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);