diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index 1cb6065a664..9409006abeb 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -1000,7 +1000,7 @@ void QNetworkReplyHttpImplPrivate::replyDownloadData(QByteArray d) QByteDataBuffer pendingDownloadDataCopy = pendingDownloadData; pendingDownloadData.clear(); - if (cacheEnabled && !cacheSaveDevice) { + if (cacheEnabled && isCachingAllowed() && !cacheSaveDevice) { initCacheSaveDevice(); } @@ -1170,7 +1170,7 @@ void QNetworkReplyHttpImplPrivate::replyDownloadProgressSlot(qint64 bytesReceive if (!q->isOpen()) return; - if (cacheEnabled && bytesReceived == bytesTotal) { + if (cacheEnabled && isCachingAllowed() && bytesReceived == bytesTotal) { // Write everything in one go if we use a download buffer. might be more performant. initCacheSaveDevice(); // need to check again if cache enabled and device exists @@ -2027,6 +2027,11 @@ void QNetworkReplyHttpImplPrivate::setCachingEnabled(bool enable) } } +bool QNetworkReplyHttpImplPrivate::isCachingAllowed() const +{ + return operation == QNetworkAccessManager::GetOperation || operation == QNetworkAccessManager::HeadOperation; +} + void QNetworkReplyHttpImplPrivate::completeCacheSave() { if (cacheEnabled && errorCode != QNetworkReplyImpl::NoError) { diff --git a/src/network/access/qnetworkreplyhttpimpl_p.h b/src/network/access/qnetworkreplyhttpimpl_p.h index 81393c2af01..956d5c207f6 100644 --- a/src/network/access/qnetworkreplyhttpimpl_p.h +++ b/src/network/access/qnetworkreplyhttpimpl_p.h @@ -214,6 +214,7 @@ public: void completeCacheSave(); void setCachingEnabled(bool enable); bool isCachingEnabled() const; + bool isCachingAllowed() const; void initCacheSaveDevice(); QIODevice *cacheLoadDevice; bool loadingFromCache;