diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-01-12 14:20:28 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-01-12 14:52:48 (GMT) |
commit | 589568759b074dd0478615f785a2297a1800d79f (patch) | |
tree | 5be4fcf0b5400c225eecfac01545da30029d8a35 /tests/auto/qabstractnetworkcache | |
parent | 4f7ebc24de5496c468e38b36aaba3ad3d877198a (diff) | |
download | Qt-589568759b074dd0478615f785a2297a1800d79f.zip Qt-589568759b074dd0478615f785a2297a1800d79f.tar.gz Qt-589568759b074dd0478615f785a2297a1800d79f.tar.bz2 |
Fix an issue with HTTP headers like "private, max-age=300".
The parsing would ignore the fact that "private" ended at the comma
and would instead try to get the continuation as the value.
We have to check if equal < comma and it's not -1. Using unsigned
comparisons does both things at once for us.
Task-number: QTBUG-7060
Reviewed-by: Peter Hartmann
Diffstat (limited to 'tests/auto/qabstractnetworkcache')
-rw-r--r-- | tests/auto/qabstractnetworkcache/tests/httpcachetest_cachecontrol200.cgi | 9 | ||||
-rw-r--r-- | tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp | 8 |
2 files changed, 16 insertions, 1 deletions
diff --git a/tests/auto/qabstractnetworkcache/tests/httpcachetest_cachecontrol200.cgi b/tests/auto/qabstractnetworkcache/tests/httpcachetest_cachecontrol200.cgi new file mode 100644 index 0000000..e44d5ed --- /dev/null +++ b/tests/auto/qabstractnetworkcache/tests/httpcachetest_cachecontrol200.cgi @@ -0,0 +1,9 @@ +#!/bin/bash +cc=`echo "${QUERY_STRING}" | sed -e s/%20/\ /g` +echo "Status: 200" +echo "Cache-Control: $cc" +echo "Last-Modified: Sat, 31 Oct 1981 06:00:00 GMT" +echo "Content-type: text/html"; +echo "X-Script: $0" +echo "" +echo "Hello World!" diff --git a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp index ac73f08..04bd432 100644 --- a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp +++ b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp @@ -205,6 +205,11 @@ void tst_QAbstractNetworkCache::cacheControl_data() QTest::newRow("304-2") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?max-age=1000, must-revalidate" << true; QTest::newRow("304-3") << QNetworkRequest::AlwaysCache << "httpcachetest_cachecontrol.cgi?max-age=1000, must-revalidate" << AlwaysTrue; QTest::newRow("304-4") << QNetworkRequest::PreferCache << "httpcachetest_cachecontrol.cgi?max-age=1000, must-revalidate" << true; + + // see QTBUG-7060 + //QTest::newRow("nokia-boston") << QNetworkRequest::PreferNetwork << "http://waplabdc.nokia-boston.com/browser/users/venkat/cache/Cache_directives/private_1b.asp" << true; + QTest::newRow("304-2b") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol200.cgi?private, max-age=1000" << true; + QTest::newRow("304-4b") << QNetworkRequest::PreferCache << "httpcachetest_cachecontrol200.cgi?private, max-age=1000" << true; } void tst_QAbstractNetworkCache::cacheControl() @@ -223,7 +228,8 @@ void tst_QAbstractNetworkCache::check() manager.setCache(diskCache); QCOMPARE(diskCache->gotData, false); - QNetworkRequest request(QUrl(TESTFILE + url)); + QUrl realUrl = url.contains("://") ? url : TESTFILE + url; + QNetworkRequest request(realUrl); // prime the cache QNetworkReply *reply = manager.get(request); |