summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkreplyhttpimpl.cpp
diff options
context:
space:
mode:
authorPeter Hartmann <peter.hartmann@nokia.com>2011-04-08 15:08:05 +0200
committerMarkus Goetz <Markus.Goetz@nokia.com>2011-05-03 16:39:32 +0200
commita5562d345b212c722b3b0a9296b0ab9187959ddf (patch)
treecc9c77498199bca88318483baa8cbdfba9c95cae /src/network/access/qnetworkreplyhttpimpl.cpp
parent2aba57d58eba4ec6033c8896516b4e24929bbe76 (diff)
HTTP caching internals: fix logic for PreferNetwork and PreferCache
Diffstat (limited to 'src/network/access/qnetworkreplyhttpimpl.cpp')
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index 3acbfff70f..1d8605810c 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -441,6 +441,11 @@ bool QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(QHttpNetworkRequest &h
httpRequest.setHeaderField("If-Modified-Since", QNetworkHeadersPrivate::toHttpDate(lastModified));
if (CacheLoadControlAttribute == QNetworkRequest::PreferNetwork) {
+ // PreferNetwork == send request with "If-None-Match" and "If-Modified-Since" header,
+ // which will return a 304 Not Modifed if resource has not been changed.
+ // We might read from cache later, if receiving a 304.
+ return false;
+ } else if (CacheLoadControlAttribute == QNetworkRequest::PreferCache) {
it = cacheHeaders.findRawHeader("Cache-Control");
if (it != cacheHeaders.rawHeaders.constEnd()) {
QHash<QByteArray, QByteArray> cacheControl = parseHttpOptionHeader(it->second);
@@ -1422,7 +1427,7 @@ QNetworkCacheMetaData QNetworkReplyHttpImplPrivate::fetchCacheMetaData(const QNe
attributes.insert(QNetworkRequest::HttpStatusCodeAttribute, statusCode);
attributes.insert(QNetworkRequest::HttpReasonPhraseAttribute, reasonPhrase);
} else {
- // this is a redirection, keep the attributes intact
+ // this is the server telling us the resource has not changed, keep the attributes intact
attributes = oldMetaData.attributes();
}
metaData.setAttributes(attributes);