summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBenjamin C Meyer <benjamin.meyer@torchmobile.com>2009-03-05 22:34:21 (GMT)
committerPeter Hartmann <peter.hartmann@trolltech.com>2009-03-30 15:44:22 (GMT)
commit2cb93d0c1f80c572c5cfa5074a6cfae81a3b28d2 (patch)
tree5ef65066b4da69d346858125cbc913d308d2cf15 /src
parent6a303f13616fe1f54086092952b0d740534ca52a (diff)
downloadQt-2cb93d0c1f80c572c5cfa5074a6cfae81a3b28d2.zip
Qt-2cb93d0c1f80c572c5cfa5074a6cfae81a3b28d2.tar.gz
Qt-2cb93d0c1f80c572c5cfa5074a6cfae81a3b28d2.tar.bz2
Improvements to follow the behavior of web servers and other browsers, specifically match the behavior of Firefox which servers test against. - When updating the cache metadata don't update content-* headers - Don't lowercase headers names when updating them - Fixed a typo in QNETWORKACCESSHTTPBACKEND_DEBUG code
Originally seen on http://www.bibelbund.de/htm/99-4-306.htm where on refresh the 304 will set the content type of text/plain. Signed-off-by: Thiago Macieira <thiago.macieira@nokia.com> Signed-off-by: Peter Hartmann <peter.hartmann@trolltech.com>
Diffstat (limited to 'src')
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index 4b41aa7..227a578 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -951,6 +951,7 @@ QNetworkCacheMetaData QNetworkAccessHttpBackend::fetchCacheMetaData(const QNetwo
QList<QByteArray> newHeaders = rawHeaderList();
foreach (QByteArray header, newHeaders) {
+ QByteArray originalHeader = header;
header = header.toLower();
bool hop_by_hop =
(header == "connection"
@@ -974,19 +975,32 @@ QNetworkCacheMetaData QNetworkAccessHttpBackend::fetchCacheMetaData(const QNetwo
continue;
}
+ it = cacheHeaders.findRawHeader(header);
+ if (it != cacheHeaders.rawHeaders.constEnd()) {
+ // Match the behavior of Firefox and assume Cache-Control: "no-transform"
+ if (header == "content-encoding"
+ || header == "content-range"
+ || header == "content-type")
+ continue;
+
+ // For MS servers that send "Content-Length: 0" on 304 responses
+ // ignore this too
+ if (header == "content-length")
+ continue;
+ }
+
#if defined(QNETWORKACCESSHTTPBACKEND_DEBUG)
QByteArray n = rawHeader(header);
QByteArray o;
- it = cacheHeaders.findRawHeader(header);
if (it != cacheHeaders.rawHeaders.constEnd())
o = (*it).second;
- if (n != o && header != "Date") {
+ if (n != o && header != "date") {
qDebug() << "replacing" << header;
qDebug() << "new" << n;
qDebug() << "old" << o;
}
#endif
- cacheHeaders.setRawHeader(header, rawHeader(header));
+ cacheHeaders.setRawHeader(originalHeader, rawHeader(header));
}
metaData.setRawHeaders(cacheHeaders.rawHeaders);