Update credentials on cached http-connections
When sending a second request with implied credentials the connection used may be cached as a connection without credentials, and thereby incorrectly reused later for other connections with different implied credentials. This patch updates the credentials a cached http-connection is using before sending a request on it. Task-number: QTBUG-39456 Change-Id: I1609234136a89c32e00432a67720cd62a73a488a Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>bb10
parent
92ce89c1ef
commit
2e207e2943
|
|
@ -385,11 +385,12 @@ void QHttpNetworkConnectionPrivate::copyCredentials(int fromChannel, QAuthentica
|
|||
Q_ASSERT(auth);
|
||||
|
||||
// NTLM is a multi phase authentication. Copying credentials between authenticators would mess things up.
|
||||
if (!isProxy && channels[fromChannel].authMethod == QAuthenticatorPrivate::Ntlm)
|
||||
return;
|
||||
if (isProxy && channels[fromChannel].proxyAuthMethod == QAuthenticatorPrivate::Ntlm)
|
||||
return;
|
||||
|
||||
if (fromChannel >= 0) {
|
||||
if (!isProxy && channels[fromChannel].authMethod == QAuthenticatorPrivate::Ntlm)
|
||||
return;
|
||||
if (isProxy && channels[fromChannel].proxyAuthMethod == QAuthenticatorPrivate::Ntlm)
|
||||
return;
|
||||
}
|
||||
|
||||
// select another channel
|
||||
QAuthenticator* otherAuth = 0;
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
class QHttpNetworkRequest;
|
||||
class QHttpNetworkReply;
|
||||
class QHttpThreadDelegate;
|
||||
class QByteArray;
|
||||
class QHostInfo;
|
||||
|
||||
|
|
@ -148,6 +149,7 @@ public:
|
|||
private:
|
||||
Q_DECLARE_PRIVATE(QHttpNetworkConnection)
|
||||
Q_DISABLE_COPY(QHttpNetworkConnection)
|
||||
friend class QHttpThreadDelegate;
|
||||
friend class QHttpNetworkReply;
|
||||
friend class QHttpNetworkReplyPrivate;
|
||||
friend class QHttpNetworkConnectionChannel;
|
||||
|
|
|
|||
|
|
@ -328,6 +328,16 @@ void QHttpThreadDelegate::startRequest()
|
|||
|
||||
// cache the QHttpNetworkConnection corresponding to this cache key
|
||||
connections.localData()->addEntry(cacheKey, httpConnection);
|
||||
} else {
|
||||
if (httpRequest.withCredentials()) {
|
||||
QNetworkAuthenticationCredential credential = authenticationManager->fetchCachedCredentials(httpRequest.url(), 0);
|
||||
if (!credential.user.isEmpty() && !credential.password.isEmpty()) {
|
||||
QAuthenticator auth;
|
||||
auth.setUser(credential.user);
|
||||
auth.setPassword(credential.password);
|
||||
httpConnection->d_func()->copyCredentials(-1, &auth, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue