summaryrefslogtreecommitdiffstats
path: root/logic/net/CacheDownload.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'logic/net/CacheDownload.cpp')
-rw-r--r--logic/net/CacheDownload.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/logic/net/CacheDownload.cpp b/logic/net/CacheDownload.cpp
index 6a76a4ae..309eb345 100644
--- a/logic/net/CacheDownload.cpp
+++ b/logic/net/CacheDownload.cpp
@@ -33,7 +33,11 @@ void CacheDownload::start()
}
QLOG_INFO() << "Downloading " << m_url.toString();
QNetworkRequest request(m_url);
- request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1());
+ if(m_entry->remote_changed_timestamp.size())
+ request.setRawHeader(QString("If-Modified-Since").toLatin1(), m_entry->remote_changed_timestamp.toLatin1());
+ if(m_entry->etag.size())
+ request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1());
+
request.setHeader(QNetworkRequest::UserAgentHeader,"MultiMC/5.0 (Cached)");
auto worker = MMC->qnam();
@@ -87,7 +91,11 @@ void CacheDownload::downloadFinished()
QFileInfo output_file_info(m_target_path);
m_entry->etag = m_reply->rawHeader("ETag").constData();
- m_entry->last_changed_timestamp =
+ if(m_reply->hasRawHeader("Last-Modified"))
+ {
+ m_entry->remote_changed_timestamp = m_reply->rawHeader("Last-Modified").constData();
+ }
+ m_entry->local_changed_timestamp =
output_file_info.lastModified().toUTC().toMSecsSinceEpoch();
m_entry->stale = false;
MMC->metacache()->updateEntry(m_entry);