qt5base-lts/tests/auto/network/access
Dong-Heon Jung 992baedb8b 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>
2014-09-12 17:51:48 +02:00
..
qabstractnetworkcache QNetworkDiskCache: fix expiration calculation heuristic with Last-Modified time 2014-09-12 17:51:48 +02:00
qftp Skip the test 'abort' of tst_qftp. 2014-03-10 20:41:43 +01:00
qhttpnetworkconnection Fix network tests relying on troll.no 2014-03-13 13:25:26 +01:00
qhttpnetworkreply QtNetwork tests: Remove DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 2014-02-25 16:47:13 +01:00
qnetworkaccessmanager QtNetwork tests: Remove DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 2014-02-25 16:47:13 +01:00
qnetworkcachemetadata QtNetwork tests: Remove DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 2014-02-25 16:47:13 +01:00
qnetworkcookie QtNetwork tests: Remove DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 2014-02-25 16:47:13 +01:00
qnetworkcookiejar QtNetwork tests: Remove DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 2014-02-25 16:47:13 +01:00
qnetworkdiskcache Added stream version into network cache file format 2014-07-17 11:28:18 +02:00
qnetworkreply QNAM: Fix CPU load for limited upload QIODevice 2014-07-25 12:56:14 +02:00
qnetworkrequest QtNetwork tests: Remove DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 2014-02-25 16:47:13 +01:00
spdy Reduce repetitive invocations of QFINDTESTDATA. 2014-07-10 07:07:30 +02:00
access.pro network: add support for the SPDY protocol 2014-02-19 21:44:15 +01:00