Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15.2, 6.2.4
-
None
Description
see attached example.
QNetworkDiskCache does not work
CacheRequestTest::CacheRequestTest() { manager = new QNetworkAccessManager(); QNetworkDiskCache *diskCache = new QNetworkDiskCache(); diskCache->setCacheDirectory("cacheDir"); manager->setCache(diskCache); connect(manager,&QNetworkAccessManager::finished,this,&CacheRequestTest::replyFinished); } void CacheRequestTest::testCache(){ QNetworkRequest request(QUrl(QString("http://qt-project.org"))); manager->get(request); // do a request preferred from cache QNetworkRequest request2(QUrl(QString("http://qt-project.org"))); request2.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); manager->get(request2); } void CacheRequestTest::replyFinished(QNetworkReply *reply) { QVariant fromCache = reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute); qDebug() << "page from cache?" << fromCache.toBool(); }
expected result : the second request return true.
Attachments
Issue Links
- is blocked by
-
QTBUG-102803 Review QNetworkRequest::CacheLoadControl
- Reported