summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-05-14 22:02:58 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-05-14 22:02:58 (GMT)
commite3fcf351dee44b4f9457a6abbed76d37fc0fbe67 (patch)
tree2c5e0a4eaedbfa1aa8145b6aef6bdd93a38f92fb /src/network
parentf36d2e5cd0655cee2a1bfb84a66400a4b7a4c454 (diff)
parentae3f20e9ce7f592c22c23e8dea6bb9feb52c8b90 (diff)
downloadQt-e3fcf351dee44b4f9457a6abbed76d37fc0fbe67.zip
Qt-e3fcf351dee44b4f9457a6abbed76d37fc0fbe67.tar.gz
Qt-e3fcf351dee44b4f9457a6abbed76d37fc0fbe67.tar.bz2
Merge branch '4.5'
Conflicts: tools/macdeployqt/shared/shared.cpp
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp42
1 files changed, 30 insertions, 12 deletions
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index 7d0438e..bd364cb 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -973,21 +973,39 @@ QNetworkCacheMetaData QNetworkAccessHttpBackend::fetchCacheMetaData(const QNetwo
if (it != cacheHeaders.rawHeaders.constEnd())
metaData.setLastModified(QNetworkHeadersPrivate::fromHttpDate(it->second));
- bool canDiskCache = true; // Everything defaults to being cacheable on disk
-
- // 14.32
- // HTTP/1.1 caches SHOULD treat "Pragma: no-cache" as if the client
- // had sent "Cache-Control: no-cache".
- it = cacheHeaders.findRawHeader("pragma");
- if (it != cacheHeaders.rawHeaders.constEnd()
- && it->second == "no-cache")
- canDiskCache = false;
+ bool canDiskCache;
+ // only cache GET replies by default, all other replies (POST, PUT, DELETE)
+ // are not cacheable by default (according to RFC 2616 section 9)
+ if (httpReply->request().operation() == QHttpNetworkRequest::Get) {
+
+ canDiskCache = true;
+ // 14.32
+ // HTTP/1.1 caches SHOULD treat "Pragma: no-cache" as if the client
+ // had sent "Cache-Control: no-cache".
+ it = cacheHeaders.findRawHeader("pragma");
+ if (it != cacheHeaders.rawHeaders.constEnd()
+ && it->second == "no-cache")
+ canDiskCache = false;
+
+ // HTTP/1.1. Check the Cache-Control header
+ if (cacheControl.contains("no-cache"))
+ canDiskCache = false;
+ else if (cacheControl.contains("no-store"))
+ canDiskCache = false;
+
+ // responses to POST might be cacheable
+ } else if (httpReply->request().operation() == QHttpNetworkRequest::Post) {
- // HTTP/1.1. Check the Cache-Control header
- if (cacheControl.contains("no-cache"))
canDiskCache = false;
- else if (cacheControl.contains("no-store"))
+ // some pages contain "expires:" and "cache-control: no-cache" field,
+ // so we only might cache POST requests if we get "cache-control: max-age ..."
+ if (cacheControl.contains("max-age"))
+ canDiskCache = true;
+
+ // responses to PUT and DELETE are not cacheable
+ } else {
canDiskCache = false;
+ }
metaData.setSaveToDisk(canDiskCache);
int statusCode = httpReply->statusCode();