diff options
author | Yigit Akcay <yigit.akcay@qt.io> | 2023-01-27 13:07:58 +0100 |
---|---|---|
committer | Yigit Akcay <yigit.akcay@qt.io> | 2023-02-13 09:12:10 +0100 |
commit | 95f70c9a0776ea0c51ec3f6c73ffb56cf9e956e6 (patch) | |
tree | 2f3e9cb19bb86cb0d443f8d43bbc38706be28177 /src/core/api | |
parent | 5358dd0dca2f19e3b4d20fa98878c9d0038cf4ce (diff) | |
download | qtwebengine-95f70c9a0776ea0c51ec3f6c73ffb56cf9e956e6.tar.gz |
QWebEngineLoadingInfo: Add response headers
This change adds a member variable that contains the response headers
to QWebEngineLoadingInfo. It is filled when a
QWebEngineLoadingInfo instance is constructed inside
WebContentsDelegateQt::emitLoadFinished(bool).
The response headers are extracted from the navigation handle when
WebContentsDelegateQt::DidFinishNavigation(content::NavigationHandle *)
is called.
The response headers are non-empty when QWebEngineLoadingInfo::status()
is equal to QWebEngineLoadingInfo::LoadSucceededStatus or
QWebEngineLoadingInfo::LoadFailedStatus.
Fixes: QTBUG-106862
Change-Id: I4d196e3cc71725ddad9a5832af72d1b4e50924c8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'src/core/api')
-rw-r--r-- | src/core/api/qwebengineloadinginfo.cpp | 23 | ||||
-rw-r--r-- | src/core/api/qwebengineloadinginfo.h | 6 |
2 files changed, 25 insertions, 4 deletions
diff --git a/src/core/api/qwebengineloadinginfo.cpp b/src/core/api/qwebengineloadinginfo.cpp index 14ec26be4..ed9618f49 100644 --- a/src/core/api/qwebengineloadinginfo.cpp +++ b/src/core/api/qwebengineloadinginfo.cpp @@ -22,13 +22,15 @@ Q_STATIC_ASSERT(static_cast<int>(WebEngineError::HttpStatusCodeDomain) == static class QWebEngineLoadingInfo::QWebEngineLoadingInfoPrivate : public QSharedData { public: QWebEngineLoadingInfoPrivate(const QUrl& url, LoadStatus status, bool isErrorPage, - const QString& errorString, int errorCode, ErrorDomain errorDomain) + const QString& errorString, int errorCode, ErrorDomain errorDomain, + const QHash<QByteArray,QByteArray>& responseHeaders) : url(url) , status(status) , isErrorPage(isErrorPage) , errorString(errorString) , errorCode(errorCode) , errorDomain(errorDomain) + , responseHeaders(responseHeaders) { } @@ -38,6 +40,7 @@ public: QString errorString; int errorCode; ErrorDomain errorDomain; + QHash<QByteArray,QByteArray> responseHeaders; }; /*! @@ -52,8 +55,10 @@ public: \sa QWebEnginePage::loadStarted, QWebEnginePage::loadFinished, WebEngineView::loadingChanged */ QWebEngineLoadingInfo::QWebEngineLoadingInfo(const QUrl& url, LoadStatus status, bool isErrorPage, - const QString& errorString, int errorCode, ErrorDomain errorDomain) - : d_ptr(new QWebEngineLoadingInfoPrivate(url, status, isErrorPage, errorString, errorCode, errorDomain)) + const QString& errorString, int errorCode, ErrorDomain errorDomain, + const QHash<QByteArray,QByteArray>& responseHeaders) + : d_ptr(new QWebEngineLoadingInfoPrivate(url, status, isErrorPage, errorString, errorCode, errorDomain, + responseHeaders)) { } @@ -157,6 +162,18 @@ int QWebEngineLoadingInfo::errorCode() const return d->errorCode; } +/*! + \property QWebEngineLoadingInfo::responseHeaders + \brief Holds the response headers when \c QWebEngineLoadingInfo::status() + is equal to \c QWebEngineLoadingInfo::LoadSucceededStatus or + \c QWebEngineLoadingInfo::LoadFailedStatus. +*/ +QHash<QByteArray,QByteArray> QWebEngineLoadingInfo::responseHeaders() const +{ + Q_D(const QWebEngineLoadingInfo); + return d->responseHeaders; +} + QT_END_NAMESPACE #include "moc_qwebengineloadinginfo.cpp" diff --git a/src/core/api/qwebengineloadinginfo.h b/src/core/api/qwebengineloadinginfo.h index a17588a57..11cce7365 100644 --- a/src/core/api/qwebengineloadinginfo.h +++ b/src/core/api/qwebengineloadinginfo.h @@ -9,6 +9,7 @@ #include <QtCore/qshareddata.h> #include <QtCore/qobject.h> #include <QtCore/qurl.h> +#include <QHash> namespace QtWebEngineCore { class WebContentsAdapter; @@ -26,6 +27,7 @@ class Q_WEBENGINECORE_EXPORT QWebEngineLoadingInfo Q_PROPERTY(QString errorString READ errorString CONSTANT FINAL) Q_PROPERTY(ErrorDomain errorDomain READ errorDomain CONSTANT FINAL) Q_PROPERTY(int errorCode READ errorCode CONSTANT FINAL) + Q_PROPERTY(QHash<QByteArray,QByteArray> responseHeaders READ responseHeaders CONSTANT FINAL) public: enum LoadStatus { @@ -60,11 +62,13 @@ public: QString errorString() const; ErrorDomain errorDomain() const; int errorCode() const; + QHash<QByteArray,QByteArray> responseHeaders() const; private: QWebEngineLoadingInfo(const QUrl &url, LoadStatus status, bool isErrorPage = false, const QString &errorString = QString(), int errorCode = 0, - ErrorDomain errorDomain = NoErrorDomain); + ErrorDomain errorDomain = NoErrorDomain, + const QHash<QByteArray, QByteArray> &responseHeaders = {}); class QWebEngineLoadingInfoPrivate; Q_DECLARE_PRIVATE(QWebEngineLoadingInfo) QExplicitlySharedDataPointer<QWebEngineLoadingInfoPrivate> d_ptr; |