summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDong-Heon Jung <dongheon.jung@lge.com>2014-08-18 12:58:56 +0900
committerJung Dong-Heon <dongheon.jung@lge.com>2014-09-12 17:51:48 +0200
commit992baedb8bab4c64af10d75f43f9aec1eae54517 (patch)
treea292545b8f65884235fe3937a14ebd33481dc077 /tests
parentf1093e06b2b2e8fd0685182979499284aec3cb59 (diff)
QNetworkDiskCache: fix expiration calculation heuristic with Last-Modified time
Heuristic with last-modified time in Qt has some problems. 1) Remove redundant expirationDate.isInvalid() check expirationDate.isInvalid is already checked. So I removed. 2) Add dateHeader.isInvalid() check The dateHeader is used in expiration calculation. I add invalid check for the dateHeader. *. The dateHeader is the origin server's Date 3) Change diff time calculation. The expirationDate is calculated with time diff. Previous calculation is // The lastModified is earlier than the currentDateTime. // The diff has negative value. int diff = currentDateTime.secsTo(lastModified); // The expirationDate is earlier than lastModified // , currentDateTime and dateHeader. expirationDate = lastModified.addSecs(diff / 10); *. currentDateTime: current time *. lastModified: last modified date in server It means that files are not cached with the heuristic. I changed diff calculation. int diff = lastModified.secsTo(dateHeader); freshness_lifetime = diff / 10; // RFC 2616 13.2.4 4) httpRequest.headerField setting If current_age is larger than 1 day, the cache MUST attach Warning 113. *. The current_age is value of age in header or elapsed time from dateHeader in Qt source code. Previous code does not check current_age is larger than 1 day correctly. // dt = 1970-01-01T00:00:00 + current_age dt.setTime_t(current_age); // currentDateTime is much bigger than 1970-01-01T00:00:00 if (dt.daysTo(currentDateTime) > 1) Task-number: QTBUG-40836 Change-Id: I4b00c3b287e6fafeea6b02681533fe75a198247e Reviewed-by: Jung Dong-Heon <dongheon.jung@lge.com> Reviewed-by: Peter Hartmann <phartmann@blackberry.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
index da86a2d14d..aca48567eb 100644
--- a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
+++ b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
@@ -203,9 +203,9 @@ void tst_QAbstractNetworkCache::lastModified_data()
QTest::newRow("304-3") << QNetworkRequest::PreferCache << "httpcachetest_lastModified304.cgi" << true;
QTest::newRow("200-0") << QNetworkRequest::AlwaysNetwork << "httpcachetest_lastModified200.cgi" << AlwaysFalse;
- QTest::newRow("200-1") << QNetworkRequest::PreferNetwork << "httpcachetest_lastModified200.cgi" << false;
+ QTest::newRow("200-1") << QNetworkRequest::PreferNetwork << "httpcachetest_lastModified200.cgi" << true;
QTest::newRow("200-2") << QNetworkRequest::AlwaysCache << "httpcachetest_lastModified200.cgi" << AlwaysTrue;
- QTest::newRow("200-3") << QNetworkRequest::PreferCache << "httpcachetest_lastModified200.cgi" << false;
+ QTest::newRow("200-3") << QNetworkRequest::PreferCache << "httpcachetest_lastModified200.cgi" << true;
}
void tst_QAbstractNetworkCache::lastModified()