2 #include <QCryptographicHash>
53 auto * data = std::get_if<HTTPData>(&Response->m_response);
54 auto *
file = std::get_if<HTTPFile>(&Response->m_response);
58 int cache = data ? (*data)->m_cacheType : (*file)->m_cacheType;
70 auto & lastmodified = data ? (*data)->m_lastModified : (*file)->m_lastModified;
71 if (!lastmodified.isValid())
72 lastmodified = QDateTime::currentDateTime();
76 bool checkifrange = !ifrange.isEmpty();
77 bool removeranges =
false;
81 QByteArray& etag = data ? (*data)->m_etag : (*file)->m_etag;
84 QByteArray hashdata = ((*file)->fileName() + lastmodified.toString(
"ddMMyyyyhhmmsszzz")).toLocal8Bit().constData();
85 etag = QCryptographicHash::hash(hashdata, QCryptographicHash::Sha224).toHex();
89 etag = QCryptographicHash::hash((*data)->constData(), QCryptographicHash::Sha224).toHex();
95 removeranges = !ifrange.contains(etag);
100 if (!nonematch.isEmpty() && (nonematch.contains(etag)))
106 auto RemoveMilliseconds = [](QDateTime& DateTime)
108 auto residual = DateTime.time().msec();
109 DateTime = DateTime.addMSecs(-residual);
112 auto ParseModified = [](
const QString& Modified)
115 #if QT_VERSION < QT_VERSION_CHECK(6,5,0)
116 time.setTimeSpec(Qt::UTC);
118 time.setTimeZone(QTimeZone(QTimeZone::UTC));
125 auto time = ParseModified(ifrange);
128 RemoveMilliseconds(lastmodified);
129 removeranges = lastmodified > time;
132 else if (Response->m_requestType ==
HTTPGet || Response->m_requestType ==
HTTPHead)
137 auto time = ParseModified(
modified);
140 RemoveMilliseconds(lastmodified);
141 if (lastmodified <= time)
150 if (removeranges && Response->m_requestHeaders && Response->m_requestHeaders->contains(
"range"))
151 Response->m_requestHeaders->replace(
"range",
"");
161 auto * data = std::get_if<HTTPData>(&Response->m_response);
162 auto *
file = std::get_if<HTTPFile>(&Response->m_response);
166 int cache = data ? (*data)->m_cacheType : (*file)->m_cacheType;
175 Response->AddHeader(
"Cache-Control",
"no-store, max-age=0");
180 QString duration {
"0"};
185 Response->AddHeader(
"Cache-Control",
"no-cache=\"Ext\",max-age=" + duration);
189 Response->AddHeader(
"ETag", QString(
"\"") + (data ? (*data)->m_etag : (*file)->m_etag) +
"\"");
193 auto & lastmodified = data ? (*data)->m_lastModified : (*file)->m_lastModified;
195 Response->AddHeader(
"Last-Modified", last);