1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 00:45:08 +00:00

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.
This commit is contained in:
Timothy Flynn 2023-04-04 16:10:19 -04:00 committed by Linus Groh
parent 26230f2ffd
commit ddb4137ed4

View file

@ -1668,7 +1668,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> 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);