summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-03-26 08:27:02 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-03-26 08:27:02 +0100
commit8f1acd29e4d39383752899d6d05d484eb9d7935b (patch)
treee749c4bebdd49ff702dfaa062902cbb6016cfd82 /tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
parent945198fd237a83348feb4537d811565a2c2cd8e0 (diff)
parent2fedce8ed8451fd9b14bc214dc26e79b0d5ab7bd (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Diffstat (limited to 'tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp')
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 0d6828797a..8627a37e12 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -3976,7 +3976,7 @@ void tst_QNetworkReply::ioGetFromHttpWithCache_data()
"HTTP/1.0 200\r\n"
"Connection: keep-alive\r\n"
"Content-Type: text/plain\r\n"
- "Cache-control: no-cache\r\n"
+ "Cache-control: no-store\r\n"
"Content-length: 8\r\n"
"\r\n"
"Reloaded";
@@ -4002,6 +4002,33 @@ void tst_QNetworkReply::ioGetFromHttpWithCache_data()
content.second = "Not-reloaded";
content.first.setLastModified(past);
+ // "no-cache"
+ rawHeaders.clear();
+ rawHeaders << QNetworkCacheMetaData::RawHeader("Date", QLocale::c().toString(past, dateFormat).toLatin1())
+ << QNetworkCacheMetaData::RawHeader("Cache-control", "no-cache");
+ content.first.setRawHeaders(rawHeaders);
+ content.first.setLastModified(past);
+ content.first.setExpirationDate(future);
+
+ // "no-cache" does not mean "no cache", just that we must consult remote first
+ QTest::newRow("no-cache,200,always-network")
+ << reply200 << "Reloaded" << content << int(QNetworkRequest::AlwaysNetwork) << QStringList() << false << true;
+ QTest::newRow("no-cache,200,prefer-network")
+ << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << false << true;
+ QTest::newRow("no-cache,200,prefer-cache")
+ << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << false << true;
+ // We're not allowed by the spec to deliver cached data without checking if it is still
+ // up-to-date.
+ QTest::newRow("no-cache,200,always-cache")
+ << reply200 << QString() << content << int(QNetworkRequest::AlwaysCache) << QStringList() << false << false;
+
+ QTest::newRow("no-cache,304,prefer-network")
+ << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << true << true;
+ QTest::newRow("no-cache,304,prefer-cache")
+ << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << true << true;
+ QTest::newRow("no-cache,304,always-cache")
+ << reply304 << QString() << content << int(QNetworkRequest::AlwaysCache) << QStringList() << false << false;
+
//
// Set to expired
//