From cebf1fea4a6802b8999469f647f52171e87d02b6 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 28 Dec 2016 15:27:57 +0100 Subject: Add redirects policy to QNetworkAccessManager This patch makes it possible to enable/disable redirects on QNAM level (before it was per-request only). This policy would be applied to all subsequent requests* created by QNAM. The policies we support at the moment: a. Manual - that's what we always had - it's up to a user to handle redirects. b. NoLessSafeRedirectsPolicy - we allow http->http, http->https and https->https redirects, but no protocol 'downgrade' (no https->http redirects). c. SameOriginPolicy - we check that protocol/host/port are the same. Updated tst_qnetworkreply. *We previously were enabling redirect for each request, by setting FollowRedirectsAttribute on QNetworkRequest object. For backward compatibility this attribute has a higher priority (if set) than QNAM's policy (and it will work as NoLessSafeRedirectsPolicy). [ChangeLog][QtNetwork] Added redirects policy to QNAM Task-number: QTPM-239 Task-number: QTPM-237 Change-Id: I493d1728254b71b61b5504937e8e01dca5953527 Reviewed-by: Timur Pocheptsov --- src/network/access/qnetworkaccessmanager.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/network/access/qnetworkaccessmanager.h') diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h index 649013cced..c0a27100e5 100644 --- a/src/network/access/qnetworkaccessmanager.h +++ b/src/network/access/qnetworkaccessmanager.h @@ -41,6 +41,7 @@ #define QNETWORKACCESSMANAGER_H #include +#include #include #ifndef QT_NO_SSL #include @@ -49,7 +50,6 @@ QT_BEGIN_NAMESPACE - class QIODevice; class QAbstractNetworkCache; class QAuthenticator; @@ -57,7 +57,6 @@ class QByteArray; template class QList; class QNetworkCookie; class QNetworkCookieJar; -class QNetworkRequest; class QNetworkReply; class QNetworkProxy; class QNetworkProxyFactory; @@ -149,6 +148,9 @@ public: #endif void connectToHost(const QString &hostName, quint16 port = 80); + void setRedirectsPolicy(QNetworkRequest::RedirectsPolicy policy); + QNetworkRequest::RedirectsPolicy redirectsPolicy() const; + Q_SIGNALS: #ifndef QT_NO_NETWORKPROXY void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator); -- cgit v1.2.3