2 #include <QCryptographicHash>
54 auto * data = std::get_if<HTTPData>(&Response->m_response);
55 auto *
file = std::get_if<HTTPFile>(&Response->m_response);
59 int cache = data ? (*data)->m_cacheType : (*file)->m_cacheType;
71 auto & lastmodified = data ? (*data)->m_lastModified : (*file)->m_lastModified;
72 if (!lastmodified.isValid())
73 lastmodified = QDateTime::currentDateTime();
77 bool checkifrange = !ifrange.isEmpty();
78 bool removeranges =
false;
82 QByteArray& etag = data ? (*data)->m_etag : (*file)->m_etag;
85 QByteArray hashdata = ((*file)->fileName() + lastmodified.toString(
"ddMMyyyyhhmmsszzz")).toLocal8Bit().constData();
86 etag = QCryptographicHash::hash(hashdata, QCryptographicHash::Sha224).toHex();
90 etag = QCryptographicHash::hash((*data)->constData(), QCryptographicHash::Sha224).toHex();
96 removeranges = !ifrange.contains(etag);
101 if (!nonematch.isEmpty() && (nonematch.contains(etag)))
107 auto RemoveMilliseconds = [](QDateTime& DateTime)
109 auto residual = DateTime.time().msec();
110 DateTime = DateTime.addMSecs(-residual);
113 auto ParseModified = [](
const QString& Modified)
116 #if QT_VERSION < QT_VERSION_CHECK(6,5,0)
117 time.setTimeSpec(Qt::UTC);
119 time.setTimeZone(QTimeZone(QTimeZone::UTC));
126 auto time = ParseModified(ifrange);
129 RemoveMilliseconds(lastmodified);
130 removeranges = lastmodified > time;
133 else if (Response->m_requestType ==
HTTPGet || Response->m_requestType ==
HTTPHead)
138 auto time = ParseModified(
modified);
141 RemoveMilliseconds(lastmodified);
142 if (lastmodified <= time)
151 if (removeranges && Response->m_requestHeaders && Response->m_requestHeaders->contains(
"range"))
152 Response->m_requestHeaders->replace(
"range",
"");
162 auto * data = std::get_if<HTTPData>(&Response->m_response);
163 auto *
file = std::get_if<HTTPFile>(&Response->m_response);
167 int cache = data ? (*data)->m_cacheType : (*file)->m_cacheType;
176 Response->AddHeader(
"Cache-Control",
"no-store, max-age=0");
181 QString duration {
"0"};
186 Response->AddHeader(
"Cache-Control",
"no-cache=\"Ext\",max-age=" + duration);
190 Response->AddHeader(
"ETag", QString(
"\"") + (data ? (*data)->m_etag : (*file)->m_etag) +
"\"");
194 auto & lastmodified = data ? (*data)->m_lastModified : (*file)->m_lastModified;
196 Response->AddHeader(
"Last-Modified", last);