From ddb4137ed4f98cd82d985813a292af4cc119d4f6 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 4 Apr 2023 16:10:19 -0400 Subject: [PATCH] LibWeb: Ensure fetch errors set their response types/codes appropriately If we fail to set the response type to an error, calling code will think the fetch was successful. We also should not default to an error code of 200, which would also indicate success. --- Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index 9289f234ed..718f6d5272 100644 --- a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -1668,7 +1668,8 @@ WebIDL::ExceptionOr> nonstandard_resource_load if (status_code.value_or(0) == 0) { response = Infrastructure::Response::network_error(vm, TRY_OR_IGNORE("HTTP request failed"_string)); } else { - response->set_status(status_code.value_or(200)); + response->set_type(Infrastructure::Response::Type::Error); + response->set_status(status_code.value_or(400)); // FIXME: Set response status message and body } pending_response->resolve(response);