summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2024-01-09 10:19:21 +0100
committerSimon Rettberg2024-01-09 10:19:21 +0100
commit534f7e8233cff59a86368f613f95d2c147304fc7 (patch)
tree415e33b6a3399be216e738fbb69680a74855a8fd
parentAdd --zoom option (diff)
downloadslxbrowser-534f7e8233cff59a86368f613f95d2c147304fc7.tar.gz
slxbrowser-534f7e8233cff59a86368f613f95d2c147304fc7.tar.xz
slxbrowser-534f7e8233cff59a86368f613f95d2c147304fc7.zip
Fix: error page not showing HTTP error codes, but "Unknown Error"HEADmaster
-rw-r--r--src/slxbrowser.cpp20
1 files 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("<html><body style='background:blue;color:white'><br><br>"
- "<center><h1>Page Load Error</h1><pre id='content'></pre><br>"
- "<p><a href='#' onclick='window.history.back()'>Back</a></p>"
+ "<center><h1>Page Load Error</h1><div id='content'></div><br>"
+ "<p><a style='color:white' href='#' onclick='window.history.back()'>Back</a></p>"
"</center></body></html>");
+ _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<QSslError>& 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);
+ }
+ }
}
}