summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKirill Burtsev <kirill.burtsev@qt.io>2022-03-24 13:46:51 +0100
committerKirill Burtsev <kirill.burtsev@qt.io>2022-04-18 08:42:38 +0200
commit4c4ac0df9cea39b8d2a78c3563dda5fee199c9e8 (patch)
tree1cebfd425ff88d4828c2d169280a48c9cf9f3b9a /src
parent20c4e8bc408770c714ea3f7c6465bc4ca65d3c09 (diff)
Introduce http status code domain for loading info
Fix inconsistency in reporting load info error category for http status codes, which across versions was reported either as internal error category or just no error domain. Add new separate domain for http status codes. [ChangeLog][QWebEngineLoadingInfo] Added HttpStatusCodeDomain for http status code range of errors Fixes: QTBUG-94963 Change-Id: I9fd496248c6fa33c424d758e9a0be99758aaf061 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Benjamin Terrier <b.terrier@gmail.com> Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/core/api/qwebengineloadinginfo.cpp3
-rw-r--r--src/core/api/qwebengineloadinginfo.h3
-rw-r--r--src/core/web_contents_delegate_qt.cpp6
-rw-r--r--src/core/web_contents_delegate_qt.h2
-rw-r--r--src/core/web_engine_error.cpp4
-rw-r--r--src/core/web_engine_error.h3
-rw-r--r--src/webenginequick/doc/src/loading_info.qdoc2
7 files changed, 18 insertions, 5 deletions
diff --git a/src/core/api/qwebengineloadinginfo.cpp b/src/core/api/qwebengineloadinginfo.cpp
index ce6e57d5c..c33a616de 100644
--- a/src/core/api/qwebengineloadinginfo.cpp
+++ b/src/core/api/qwebengineloadinginfo.cpp
@@ -53,6 +53,7 @@ Q_STATIC_ASSERT(static_cast<int>(WebEngineError::CertificateErrorDomain) == stat
Q_STATIC_ASSERT(static_cast<int>(WebEngineError::HttpErrorDomain) == static_cast<int>(ErrorDomain::HttpErrorDomain));
Q_STATIC_ASSERT(static_cast<int>(WebEngineError::FtpErrorDomain) == static_cast<int>(ErrorDomain::FtpErrorDomain));
Q_STATIC_ASSERT(static_cast<int>(WebEngineError::DnsErrorDomain) == static_cast<int>(ErrorDomain::DnsErrorDomain));
+Q_STATIC_ASSERT(static_cast<int>(WebEngineError::HttpStatusCodeDomain) == static_cast<int>(ErrorDomain::HttpStatusCodeDomain));
class QWebEngineLoadingInfo::QWebEngineLoadingInfoPrivate : public QSharedData {
public:
@@ -169,6 +170,8 @@ QString QWebEngineLoadingInfo::errorString() const
Error is related to the FTP connection.
\value DnsErrorDomain
Error is related to the DNS connection.
+ \value HttpStatusCodeDomain
+ Error is the HTTP response status code, even in case of success e.g. the server replied with status 200.
*/
/*
\property QWebEngineLoadingInfo::errorDomain
diff --git a/src/core/api/qwebengineloadinginfo.h b/src/core/api/qwebengineloadinginfo.h
index a8b7233ac..40b763e59 100644
--- a/src/core/api/qwebengineloadinginfo.h
+++ b/src/core/api/qwebengineloadinginfo.h
@@ -79,7 +79,8 @@ public:
CertificateErrorDomain,
HttpErrorDomain,
FtpErrorDomain,
- DnsErrorDomain
+ DnsErrorDomain,
+ HttpStatusCodeDomain
};
Q_ENUM(ErrorDomain)
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index edd7df452..53e45028c 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -393,9 +393,9 @@ void WebContentsDelegateQt::emitLoadFinished(bool isErrorPage)
? QWebEngineLoadingInfo::LoadSucceededStatus
: (m_loadingInfo.errorCode == WebEngineError::UserAbortedError
? QWebEngineLoadingInfo::LoadStoppedStatus : QWebEngineLoadingInfo::LoadFailedStatus);
- auto errorDomain = static_cast<QWebEngineLoadingInfo::ErrorDomain>(WebEngineError::toQtErrorDomain(m_loadingInfo.errorCode));
QWebEngineLoadingInfo info(m_loadingInfo.url, loadStatus, m_loadingInfo.isErrorPage,
- m_loadingInfo.errorDescription, m_loadingInfo.errorCode, errorDomain);
+ m_loadingInfo.errorDescription, m_loadingInfo.errorCode,
+ QWebEngineLoadingInfo::ErrorDomain(m_loadingInfo.errorDomain));
m_viewClient->loadFinished(std::move(info));
m_viewClient->updateNavigationActions();
}
@@ -480,6 +480,7 @@ void WebContentsDelegateQt::didFailLoad(const QUrl &url, int errorCode, const QS
m_loadingInfo.success = false;
m_loadingInfo.url = url;
m_loadingInfo.errorCode = errorCode;
+ m_loadingInfo.errorDomain = WebEngineError::toQtErrorDomain(errorCode);
m_loadingInfo.errorDescription = errorDescription;
m_loadingInfo.triggersErrorPage = errorPageEnabled && !aborted;
}
@@ -527,6 +528,7 @@ void WebContentsDelegateQt::DidFinishLoad(content::RenderFrameHost* render_frame
m_loadingInfo.success = http_statuscode < 400;
m_loadingInfo.url = toQt(validated_url);
m_loadingInfo.errorCode = http_statuscode;
+ m_loadingInfo.errorDomain = WebEngineError::toQtErrorDomain(http_statuscode);
m_loadingInfo.errorDescription = WebEngineError::toQtErrorDescription(http_statuscode);
m_loadingInfo.triggersErrorPage = triggersErrorPage;
}
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 669424712..e593da789 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -235,7 +235,7 @@ private:
bool isLoading() const { return progress >= 0; }
QUrl url;
bool isErrorPage = false;
- int errorCode = 0;
+ int errorCode = 0, errorDomain = 0;
QString errorDescription;
bool triggersErrorPage = false;
void clear() { *this = LoadingInfo(); }
diff --git a/src/core/web_engine_error.cpp b/src/core/web_engine_error.cpp
index a6580d76b..ff46be5c8 100644
--- a/src/core/web_engine_error.cpp
+++ b/src/core/web_engine_error.cpp
@@ -65,6 +65,10 @@ const int endErrors = -900;
WebEngineError::ErrorDomain WebEngineError::toQtErrorDomain(int error_code)
{
+ // net errors are always negative values, and https response codes are positive
+ if (error_code > 0)
+ return HttpStatusCodeDomain;
+
// Chromium's ranges from net/base/net_error_list.h:
// 0 No error
// 1- 99 System related errors
diff --git a/src/core/web_engine_error.h b/src/core/web_engine_error.h
index 0ef0950ae..b3373c0d5 100644
--- a/src/core/web_engine_error.h
+++ b/src/core/web_engine_error.h
@@ -64,7 +64,8 @@ public:
CertificateErrorDomain,
HttpErrorDomain,
FtpErrorDomain,
- DnsErrorDomain
+ DnsErrorDomain,
+ HttpStatusCodeDomain
};
static const int UserAbortedError;
diff --git a/src/webenginequick/doc/src/loading_info.qdoc b/src/webenginequick/doc/src/loading_info.qdoc
index fe8e30a80..a85af8818 100644
--- a/src/webenginequick/doc/src/loading_info.qdoc
+++ b/src/webenginequick/doc/src/loading_info.qdoc
@@ -79,6 +79,8 @@
Error is related to the FTP connection.
\value WebEngineLoadingInfo.DnsErrorDomain
Error is related to the DNS connection.
+ \value WebEngineLoadingInfo.HttpStatusCodeDomain
+ Error is the HTTP response status code, even in case of success e.g. the server replied with status 200.
*/
/*!
\qmlproperty int WebEngineLoadingInfo::errorCode