From 534f7e8233cff59a86368f613f95d2c147304fc7 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 9 Jan 2024 10:19:21 +0100 Subject: Fix: error page not showing HTTP error codes, but "Unknown Error" --- src/slxbrowser.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/slxbrowser.cpp b/src/slxbrowser.cpp index 2bfb617..8eceea0 100644 --- a/src/slxbrowser.cpp +++ b/src/slxbrowser.cpp @@ -131,10 +131,12 @@ void SlxBrowser::loadFinished(bool ok) "Dieser Link führt auf eine nicht erlaubte Seite.")); }); } else { + _browser->blockSignals(true); _browser->page()->mainFrame()->setHtml("

" - "

Page Load Error


" - "

Back

" + "

Page Load Error


" + "

Back

" "
"); + _browser->blockSignals(false); QWebElement el = _browser->page()->mainFrame()->documentElement().findFirst("#content"); QString str; if (!_sslErrors.empty()) { @@ -143,7 +145,7 @@ void SlxBrowser::loadFinished(bool ok) str.append(err.errorString()); str.append('\n'); } - } else if (_normalError.length() != 0) { + } else if (!_normalError.isEmpty()) { str.append("Load Error:\n"); str.append(_normalError); } else { @@ -183,6 +185,9 @@ void SlxBrowser::sslErrors(QNetworkReply* reply, const QList& errors) reply->ignoreSslErrors(); return; } + for (const auto& err : errors) { + qDebug() << "SSL:" << err; + } _sslErrors.append(errors); } @@ -192,9 +197,14 @@ void SlxBrowser::requestFinished(QNetworkReply *reply) _unsupportedUri = true; } else if (reply->error() == QNetworkReply::UnknownNetworkError) { _blockedSite = true; - } else { - //qDebug() << reply->error(); + } else { _normalError = reply->errorString(); + if (_normalError.isEmpty()) { + int ec = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + if (ec >= 400) { + _normalError = QString::asprintf("HTTP ERROR %d", ec); + } + } } } -- cgit v1.2.3-55-g7522