summaryrefslogtreecommitdiffstats
path: root/src/network/access
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-10-19 14:05:21 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-10-27 12:40:26 (GMT)
commit9bc5a32b875b812c3a706034c8c27614f86bd138 (patch)
tree28fe90b3a16516bc46d9efdb3c5337f0e1889741 /src/network/access
parentd18292563cc6bfee3876b830420b1f29c0a6c260 (diff)
downloadQt-9bc5a32b875b812c3a706034c8c27614f86bd138.zip
Qt-9bc5a32b875b812c3a706034c8c27614f86bd138.tar.gz
Qt-9bc5a32b875b812c3a706034c8c27614f86bd138.tar.bz2
QNAM HTTP: Move caching of credentials from URL
The credentials are now cached when the request gets sent. Reviewed-by: Peter Hartmann Reviewed-by: Prasanth Task-Number: QTBUG-13234
Diffstat (limited to 'src/network/access')
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp11
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp1
2 files changed, 6 insertions, 6 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index ccdbb20..54a7548 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -338,13 +338,9 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket
copyCredentials(i, auth, isProxy);
QMetaObject::invokeMethod(q, "_q_restartAuthPendingRequests", Qt::QueuedConnection);
}
- } else if (priv->phase == QAuthenticatorPrivate::Start) {
- // If the url's authenticator has a 'user' set we will end up here (phase is only set to 'Done' by
- // parseHttpResponse above if 'user' is empty). So if credentials were supplied with the request,
- // such as in the case of an XMLHttpRequest, this is our only opportunity to cache them.
- emit q->cacheCredentials(reply->request(), auth, q);
}
- // - Changing values in QAuthenticator will reset the 'phase'.
+ // - Changing values in QAuthenticator will reset the 'phase'. Therefore if it is still "Done"
+ // then nothing was filled in by the user or the cache
// - If withCredentials has been set to false (e.g. by QtWebKit for a cross-origin XMLHttpRequest) then
// we need to bail out if authentication is required.
if (priv->phase == QAuthenticatorPrivate::Done || !reply->request().withCredentials()) {
@@ -380,6 +376,7 @@ void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket,
int i = indexOf(socket);
+ // Send "Authorization" header, but not if it's NTLM and the socket is already authenticated.
if (channels[i].authMehtod != QAuthenticatorPrivate::None) {
if (!(channels[i].authMehtod == QAuthenticatorPrivate::Ntlm && channels[i].lastStatus != 401)) {
QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].authenticator);
@@ -389,6 +386,8 @@ void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket,
}
}
}
+
+ // Send "Proxy-Authorization" header, but not if it's NTLM and the socket is already authenticated.
if (channels[i].proxyAuthMehtod != QAuthenticatorPrivate::None) {
if (!(channels[i].proxyAuthMehtod == QAuthenticatorPrivate::Ntlm && channels[i].lastStatus != 407)) {
QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].proxyAuthenticator);
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index d10f951..f83e7c1 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -190,6 +190,7 @@ bool QHttpNetworkConnectionChannel::sendRequest()
|| (!url.password().isEmpty() && url.password() != auth.password())) {
auth.setUser(url.userName());
auth.setPassword(url.password());
+ emit connection->cacheCredentials(request, &auth, connection);
connection->d_func()->copyCredentials(connection->d_func()->indexOf(socket), &auth, false);
}
// clear the userinfo, since we use the same request for resending