]> git.sur5r.net Git - minitube/blobdiff - lib/http/src/cachedhttp.cpp
New upstream version 3.5
[minitube] / lib / http / src / cachedhttp.cpp
index 9762143e56c59c73db4145ba2e4adc2a91b2b5a6..e05534209c47e95ef7d1deff9388b7daad9579f9 100644 (file)
@@ -1,19 +1,6 @@
 #include "cachedhttp.h"
 #include "localcache.h"
 
-namespace {
-
-QByteArray requestHash(const HttpRequest &req) {
-    const char sep = '|';
-    QByteArray s = req.url.toEncoded() + sep + req.body + sep + QByteArray::number(req.offset);
-    if (req.operation == QNetworkAccessManager::PostOperation) {
-        s.append(sep);
-        s.append("POST");
-    }
-    return LocalCache::hash(s);
-}
-} // namespace
-
 CachedHttpReply::CachedHttpReply(const QByteArray &body, const HttpRequest &req)
     : bytes(body), req(req) {
     QTimer::singleShot(0, this, SLOT(emitSignals()));
@@ -69,3 +56,20 @@ HttpReply *CachedHttp::request(const HttpRequest &req) {
     qDebug() << "MISS" << key << req.url;
     return new WrappedHttpReply(cache, key, http.request(req));
 }
+
+QByteArray CachedHttp::requestHash(const HttpRequest &req) {
+    const char sep = '|';
+
+    QByteArray s;
+    if (ignoreHostname) {
+        s = (req.url.scheme() + sep + req.url.path() + sep + req.url.query()).toUtf8();
+    } else {
+        s = req.url.toEncoded();
+    }
+    s += sep + req.body + sep + QByteArray::number(req.offset);
+    if (req.operation == QNetworkAccessManager::PostOperation) {
+        s.append(sep);
+        s.append("POST");
+    }
+    return LocalCache::hash(s);
+}