summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-01-07 12:51:48 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-01-08 09:00:07 (GMT)
commite49aee9f7f82a004f41dc83ac1139e1897fa90ee (patch)
treea716159c70ce80e6ecbe02d9e488d4163d4abdd4 /src
parent73f7772da8271428ec80efed00c8881638149e46 (diff)
downloadQt-e49aee9f7f82a004f41dc83ac1139e1897fa90ee.zip
Qt-e49aee9f7f82a004f41dc83ac1139e1897fa90ee.tar.gz
Qt-e49aee9f7f82a004f41dc83ac1139e1897fa90ee.tar.bz2
QNAM HTTP: change the caching semantics to match documentation
PreferCache should not use the network even if must-revalidate is set. But if it is not fresh enough, then it should use the network. Reviewed-by: Peter Hartmann
Diffstat (limited to 'src')
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index efd0a93..c2a4079 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -385,6 +385,15 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest,
QNetworkHeadersPrivate::RawHeadersList::ConstIterator it;
cacheHeaders.setAllRawHeaders(metaData.rawHeaders());
+ if (CacheLoadControlAttribute == QNetworkRequest::PreferNetwork) {
+ it = cacheHeaders.findRawHeader("Cache-Control");
+ if (it != cacheHeaders.rawHeaders.constEnd()) {
+ QHash<QByteArray, QByteArray> cacheControl = parseHttpOptionHeader(it->second);
+ if (cacheControl.contains("must-revalidate"))
+ return;
+ }
+ }
+
it = cacheHeaders.findRawHeader("etag");
if (it != cacheHeaders.rawHeaders.constEnd())
httpRequest.setHeaderField("If-None-Match", it->second);
@@ -393,12 +402,6 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest,
if (lastModified.isValid())
httpRequest.setHeaderField("If-Modified-Since", QNetworkHeadersPrivate::toHttpDate(lastModified));
- it = cacheHeaders.findRawHeader("Cache-Control");
- if (it != cacheHeaders.rawHeaders.constEnd()) {
- QHash<QByteArray, QByteArray> cacheControl = parseHttpOptionHeader(it->second);
- if (cacheControl.contains("must-revalidate"))
- return;
- }
/*
* age_value
@@ -462,7 +465,7 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest,
int freshness_lifetime = dateHeader.secsTo(expirationDate);
bool response_is_fresh = (freshness_lifetime > current_age);
- if (!response_is_fresh && CacheLoadControlAttribute == QNetworkRequest::PreferNetwork)
+ if (!response_is_fresh)
return;
loadedFromCache = true;