summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkaccessmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/access/qnetworkaccessmanager.cpp')
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 8c17916..5ae1078 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -1014,16 +1014,8 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
priv->manager = this;
// second step: fetch cached credentials
- if (static_cast<QNetworkRequest::LoadControl>
- (request.attribute(QNetworkRequest::AuthenticationReuseAttribute,
- QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic) {
- QNetworkAuthenticationCredential *cred = d->fetchCachedCredentials(url);
- if (cred) {
- url.setUserName(cred->user);
- url.setPassword(cred->password);
- priv->urlForLastAuthentication = url;
- }
- }
+ // This is not done for the time being, we should use signal emissions to request
+ // the credentials from cache.
// third step: find a backend
priv->backend = d->findBackend(op, request);
@@ -1105,7 +1097,9 @@ void QNetworkAccessManagerPrivate::authenticationRequired(QNetworkAccessBackend
// don't try the cache for the same URL twice in a row
// being called twice for the same URL means the authentication failed
- if (url != backend->reply->urlForLastAuthentication) {
+ // also called when last URL is empty, e.g. on first call
+ if (backend->reply->urlForLastAuthentication.isEmpty()
+ || url != backend->reply->urlForLastAuthentication) {
QNetworkAuthenticationCredential *cred = fetchCachedCredentials(url, authenticator);
if (cred) {
authenticator->setUser(cred->user);
@@ -1117,7 +1111,7 @@ void QNetworkAccessManagerPrivate::authenticationRequired(QNetworkAccessBackend
backend->reply->urlForLastAuthentication = url;
emit q->authenticationRequired(backend->reply->q_func(), authenticator);
- addCredentials(url, authenticator);
+ cacheCredentials(url, authenticator);
}
#ifndef QT_NO_NETWORKPROXY
@@ -1134,7 +1128,7 @@ void QNetworkAccessManagerPrivate::proxyAuthenticationRequired(QNetworkAccessBac
// possible solution: some tracking inside the authenticator
// or a new function proxyAuthenticationSucceeded(true|false)
if (proxy != backend->reply->lastProxyAuthentication) {
- QNetworkAuthenticationCredential *cred = fetchCachedCredentials(proxy);
+ QNetworkAuthenticationCredential *cred = fetchCachedProxyCredentials(proxy);
if (cred) {
authenticator->setUser(cred->user);
authenticator->setPassword(cred->password);
@@ -1144,10 +1138,10 @@ void QNetworkAccessManagerPrivate::proxyAuthenticationRequired(QNetworkAccessBac
backend->reply->lastProxyAuthentication = proxy;
emit q->proxyAuthenticationRequired(proxy, authenticator);
- addCredentials(proxy, authenticator);
+ cacheProxyCredentials(proxy, authenticator);
}
-void QNetworkAccessManagerPrivate::addCredentials(const QNetworkProxy &p,
+void QNetworkAccessManagerPrivate::cacheProxyCredentials(const QNetworkProxy &p,
const QAuthenticator *authenticator)
{
Q_ASSERT(authenticator);
@@ -1184,7 +1178,7 @@ void QNetworkAccessManagerPrivate::addCredentials(const QNetworkProxy &p,
}
QNetworkAuthenticationCredential *
-QNetworkAccessManagerPrivate::fetchCachedCredentials(const QNetworkProxy &p,
+QNetworkAccessManagerPrivate::fetchCachedProxyCredentials(const QNetworkProxy &p,
const QAuthenticator *authenticator)
{
QNetworkProxy proxy = p;
@@ -1236,7 +1230,7 @@ QList<QNetworkProxy> QNetworkAccessManagerPrivate::queryProxy(const QNetworkProx
}
#endif
-void QNetworkAccessManagerPrivate::addCredentials(const QUrl &url,
+void QNetworkAccessManagerPrivate::cacheCredentials(const QUrl &url,
const QAuthenticator *authenticator)
{
Q_ASSERT(authenticator);