From 137972074277f0e782728d98267970dd5247cab1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 24 Feb 2023 15:12:32 +0100 Subject: [PATCH] Ladybird: Consider HTTP response a success if it has a status code The QNetworkReply::NetworkError enum mixes all kinds of errors into one enum, HTTP errors, network errors, proxy errors, etc. Instead of caring about it, we now say that HTTP requests were successful if their response has any HTTP status code attached. This allows LibWeb to display error pages when using Qt networking. --- Ladybird/RequestManagerQt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ladybird/RequestManagerQt.cpp b/Ladybird/RequestManagerQt.cpp index c5a1bc3e11..81b9640f41 100644 --- a/Ladybird/RequestManagerQt.cpp +++ b/Ladybird/RequestManagerQt.cpp @@ -84,7 +84,6 @@ RequestManagerQt::Request::~Request() = default; void RequestManagerQt::Request::did_finish() { - bool success = m_reply.error() == QNetworkReply::NetworkError::NoError; auto buffer = m_reply.readAll(); auto http_status_code = m_reply.attribute(QNetworkRequest::Attribute::HttpStatusCodeAttribute).toInt(); HashMap response_headers; @@ -106,5 +105,6 @@ void RequestManagerQt::Request::did_finish() if (!set_cookie_headers.is_empty()) { response_headers.set("set-cookie"sv, JsonArray { set_cookie_headers }.to_deprecated_string()); } + bool success = http_status_code != 0; on_buffered_request_finish(success, buffer.length(), response_headers, http_status_code, ReadonlyBytes { buffer.data(), (size_t)buffer.size() }); }