LibWeb: Render HTML content if present for HTTP error pages

If an HTTP response fails with an error code (e.g 403) but still has
body content, we now render the content.

We only fall back to our own built-in error page if there's no body.
This commit is contained in:
Andreas Kling 2023-02-24 15:00:56 +01:00 committed by Linus Groh
parent 47f5a3ea9a
commit 3435820e1f
Notes: sideshowbarker 2024-07-16 23:49:43 +09:00

View File

@ -322,7 +322,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
store_response_cookies(request.page().value(), request.url(), *set_cookie);
}
if (!success || (status_code.has_value() && *status_code >= 400 && *status_code <= 599)) {
if (!success || (status_code.has_value() && *status_code >= 400 && *status_code <= 599 && payload.is_empty())) {
StringBuilder error_builder;
if (status_code.has_value())
error_builder.appendff("Load failed: {}", *status_code);