Revise filtering of Content-Length in HTTP cache control

We filter out Content-Length from the cache metadata due to IIS
sending it bogusly on 304 responses; however, we were only doing this
if the cached response had a Content-Length header, which doesn't
happen when the original request was delivered chunked.  Furthermore,
the filtering wasn't limited to the case of 304 responses.  So skip
the "had it previously" requirement and only do this for 304s.

Fixes: QTBUG-72035
Change-Id: Ie5d858e0f0205bf68f0a13a9c9d4a6e844cb3568
Reviewed-by: Joni Poikelin <joni.poikelin@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Edward Welbourne 2018-12-04 11:35:06 +01:00
parent f184f1a481
commit b60c642ec0

View File

@ -1676,13 +1676,13 @@ QNetworkCacheMetaData QNetworkReplyHttpImplPrivate::fetchCacheMetaData(const QNe
|| 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;
}
// IIS has been known to send "Content-Length: 0" on 304 responses, so
// ignore this too
if (header == "content-length" && statusCode == 304)
continue;
#if defined(QNETWORKACCESSHTTPBACKEND_DEBUG)
QByteArray n = q->rawHeader(header);
QByteArray o;