diff options
5 files changed, 14 insertions, 11 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index f8f7620..f6cb530 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -350,7 +350,7 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket if (priv->phase == QAuthenticatorPrivate::Done) { pauseConnection(); if (!isProxy) { - emit q->authenticationRequired(reply->request(), auth, q); + emit q->authenticationRequired(reply, reply->request(), auth, q); #ifndef QT_NO_NETWORKPROXY } else { emit q->proxyAuthenticationRequired(networkProxy, auth, q); diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h index f2e0b1c..875c978 100644 --- a/src/network/access/qhttpnetworkconnection_p.h +++ b/src/network/access/qhttpnetworkconnection_p.h @@ -131,7 +131,7 @@ Q_SIGNALS: void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator, const QHttpNetworkConnection *connection = 0); #endif - void authenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *authenticator, + void authenticationRequired(const QHttpNetworkReply*, const QHttpNetworkRequest &request, QAuthenticator *authenticator, const QHttpNetworkConnection *connection = 0); void cacheCredentials(const QHttpNetworkRequest &request, QAuthenticator *authenticator, const QHttpNetworkConnection *connection = 0); diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index f617244..2af4987 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -344,8 +344,8 @@ void QNetworkAccessHttpBackend::setupConnection() connect(http, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); #endif - connect(http, SIGNAL(authenticationRequired(QHttpNetworkRequest,QAuthenticator*)), - SLOT(httpAuthenticationRequired(QHttpNetworkRequest,QAuthenticator*))); + connect(http, SIGNAL(authenticationRequired(const QHttpNetworkReply*, QHttpNetworkRequest,QAuthenticator*,const QHttpNetworkConnection*)), + SLOT(httpAuthenticationRequired(const QHttpNetworkReply*, QHttpNetworkRequest,QAuthenticator*))); connect(http, SIGNAL(cacheCredentials(QHttpNetworkRequest,QAuthenticator*)), SLOT(httpCacheCredentials(QHttpNetworkRequest,QAuthenticator*))); connect(http, SIGNAL(error(QNetworkReply::NetworkError,QString)), @@ -862,10 +862,13 @@ void QNetworkAccessHttpBackend::replyHeaderChanged() metaDataChanged(); } -void QNetworkAccessHttpBackend::httpAuthenticationRequired(const QHttpNetworkRequest &, +void QNetworkAccessHttpBackend::httpAuthenticationRequired(const QHttpNetworkReply *reply, + const QHttpNetworkRequest &, QAuthenticator *auth) { - authenticationRequired(auth); + // Only process this signal when it is for the QHttpNetworkReply that we actually have + if (reply == this->httpReply) + authenticationRequired(auth); } void QNetworkAccessHttpBackend::httpCacheCredentials(const QHttpNetworkRequest &, diff --git a/src/network/access/qnetworkaccesshttpbackend_p.h b/src/network/access/qnetworkaccesshttpbackend_p.h index c4c88ae..f06f364 100644 --- a/src/network/access/qnetworkaccesshttpbackend_p.h +++ b/src/network/access/qnetworkaccesshttpbackend_p.h @@ -104,7 +104,7 @@ private slots: void replyReadyRead(); void replyFinished(); void replyHeaderChanged(); - void httpAuthenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *auth); + void httpAuthenticationRequired(const QHttpNetworkReply*, const QHttpNetworkRequest &request, QAuthenticator *auth); void httpCacheCredentials(const QHttpNetworkRequest &request, QAuthenticator *auth); void httpError(QNetworkReply::NetworkError error, const QString &errorString); bool sendCacheContents(const QNetworkCacheMetaData &metaData); diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 89f608e..c0f503b 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -57,7 +57,7 @@ public: public Q_SLOTS: void finishedReply(); void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail); - void challenge401(const QHttpNetworkRequest &request, QAuthenticator *authenticator, const QHttpNetworkConnection *connection); + void challenge401(const QHttpNetworkReply*, const QHttpNetworkRequest &request, QAuthenticator *authenticator, const QHttpNetworkConnection *connection); #ifndef QT_NO_OPENSSL void sslErrors(const QList<QSslError> &errors); #endif @@ -495,7 +495,7 @@ void tst_QHttpNetworkConnection::_connect() QVERIFY(false); } -void tst_QHttpNetworkConnection::challenge401(const QHttpNetworkRequest &request, +void tst_QHttpNetworkConnection::challenge401(const QHttpNetworkReply*, const QHttpNetworkRequest &request, QAuthenticator *authenticator, const QHttpNetworkConnection *connection) { @@ -552,8 +552,8 @@ void tst_QHttpNetworkConnection::get401() if (encrypt) connection.enableEncryption(); QCOMPARE(connection.isEncrypted(), encrypt); - connect(&connection, SIGNAL(authenticationRequired(const QHttpNetworkRequest&, QAuthenticator *, const QHttpNetworkConnection*)), - SLOT(challenge401(const QHttpNetworkRequest&, QAuthenticator *, const QHttpNetworkConnection*))); + connect(&connection, SIGNAL(authenticationRequired(const QHttpNetworkReply*, const QHttpNetworkRequest&, QAuthenticator *, const QHttpNetworkConnection*)), + SLOT(challenge401(const QHttpNetworkReply*, const QHttpNetworkRequest&, QAuthenticator *, const QHttpNetworkConnection*))); connection.setProperty("setCredentials", setCredentials); connection.setProperty("username", username); connection.setProperty("password", password); |