From d5560e2cc3271138cf977ebd83f346a375278fd8 Mon Sep 17 00:00:00 2001 From: Robert Hogan Date: Mon, 1 Nov 2010 14:01:22 +0100 Subject: QNAM HTTP: Do not set cache headers when already set by user Qt clobbers the cache-control headers set by WebCore when CacheLoadControlAttribute == QNetworkRequest::AlwaysNetwork. This causes at least one QtWebKit layout test to fail: http/tests/misc/refresh-headers.php Qt needs to detect if the client has already made a cache-control decision in the headers before overwriting them. See https://bugs.webkit.org/show_bug.cgi?id=45598 Task-Number: QTBUG-13564 Merge-request: 2472 Reviewed-by: Markus Goetz --- src/network/access/qnetworkaccesshttpbackend.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index 42dc33d..1d85f3a 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -353,10 +353,12 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, QNetworkRequest::CacheLoadControl CacheLoadControlAttribute = (QNetworkRequest::CacheLoadControl)request().attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(); if (CacheLoadControlAttribute == QNetworkRequest::AlwaysNetwork) { - // forced reload from the network - // tell any caching proxy servers to reload too - httpRequest.setHeaderField("Cache-Control", "no-cache"); - httpRequest.setHeaderField("Pragma", "no-cache"); + // If the request does not already specify preferred cache-control + // force reload from the network and tell any caching proxy servers to reload too + if (!request().rawHeaderList().contains("Cache-Control")) { + httpRequest.setHeaderField("Cache-Control", "no-cache"); + httpRequest.setHeaderField("Pragma", "no-cache"); + } return; } -- cgit v0.12