diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-10-22 13:25:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2014-11-03 10:51:07 +0100 |
commit | 2e207e29436cbe953df99783a9577a9776a200bb (patch) | |
tree | 9e684757c067cde0cd563ede69460d2e3ad9cc6d /src/network/access/qhttpthreaddelegate.cpp | |
parent | 92ce89c1efdb7ddb589528901087e4ff50e55fe2 (diff) |
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>
Diffstat (limited to 'src/network/access/qhttpthreaddelegate.cpp')
-rw-r--r-- | src/network/access/qhttpthreaddelegate.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp index 524042add6..b13c21d624 100644 --- a/src/network/access/qhttpthreaddelegate.cpp +++ b/src/network/access/qhttpthreaddelegate.cpp @@ -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); + } + } } |