diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-01-07 12:54:28 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-01-08 09:00:07 (GMT) |
commit | 2f10f91596b12b5b0c7d57b4575ea4e3b232ee0a (patch) | |
tree | 369c4cd874831e766ef04385b3a7264ff63cb76b /src/network/access | |
parent | e49aee9f7f82a004f41dc83ac1139e1897fa90ee (diff) | |
download | Qt-2f10f91596b12b5b0c7d57b4575ea4e3b232ee0a.zip Qt-2f10f91596b12b5b0c7d57b4575ea4e3b232ee0a.tar.gz Qt-2f10f91596b12b5b0c7d57b4575ea4e3b232ee0a.tar.bz2 |
QNAM HTTP: just use the expirationDate in the code that validates the cache
The max-age handling is already done in the cache-saving code.
Reviewed-by: Peter Hartmann
Diffstat (limited to 'src/network/access')
-rw-r--r-- | src/network/access/qnetworkaccesshttpbackend.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index c2a4079..12b10f9 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -402,7 +402,10 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, if (lastModified.isValid()) httpRequest.setHeaderField("If-Modified-Since", QNetworkHeadersPrivate::toHttpDate(lastModified)); + QDateTime currentDateTime = QDateTime::currentDateTime(); + QDateTime expirationDate = metaData.expirationDate(); +#if 0 /* * age_value * is the value of Age: header received by the cache with @@ -418,7 +421,6 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, * now * is the current (local) time */ - QDateTime currentDateTime = QDateTime::currentDateTime(); int age_value = 0; it = cacheHeaders.findRawHeader("age"); if (it != cacheHeaders.rawHeaders.constEnd()) @@ -445,7 +447,6 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, int current_age = corrected_initial_age + resident_time; // RFC 2616 13.2.4 Expiration Calculations - QDateTime expirationDate = metaData.expirationDate(); if (!expirationDate.isValid()) { if (lastModified.isValid()) { int diff = currentDateTime.secsTo(lastModified); @@ -464,6 +465,9 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, // if "max-age" is present, or to Expires otherwise int freshness_lifetime = dateHeader.secsTo(expirationDate); bool response_is_fresh = (freshness_lifetime > current_age); +#else + bool response_is_fresh = currentDateTime.secsTo(expirationDate) >= 0; +#endif if (!response_is_fresh) return; |