From e543552dbd72292f0eb1567402db32370adf0023 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 13 Aug 2012 15:09:55 +0200 Subject: [PATCH] [FIX] do not mess up the headers in the DisableCacheMiddleware bzr revid: chs@openerp.com-20120813130955-1fwkyahlceotln5o --- addons/web/common/http.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/addons/web/common/http.py b/addons/web/common/http.py index 6b1a28e5803..6c71e4696b5 100644 --- a/addons/web/common/http.py +++ b/addons/web/common/http.py @@ -382,7 +382,7 @@ def session_context(request, storage_path, session_cookie='sessionid'): # note that domains_store and contexts_store are append-only (we # only ever add items to them), so we can just update one with the # other to get the right result, if we want to merge the - # ``context`` dict we'll need something smarter + # ``context`` dict we'll need something smarter in_store = session_store.get(sid) for k, v in request.session.iteritems(): stored = in_store.get(k) @@ -426,13 +426,18 @@ class DisableCacheMiddleware(object): referer = environ.get('HTTP_REFERER', '') parsed = urlparse.urlparse(referer) debug = parsed.query.count('debug') >= 1 - nh = dict(headers) - if 'Last-Modified' in nh: del nh['Last-Modified'] + + new_headers = [] + unwanted_keys = ['Last-Modified'] if debug: - if 'Expires' in nh: del nh['Expires'] - if 'Etag' in nh: del nh['Etag'] - nh['Cache-Control'] = 'no-cache' - start_response(status, nh.items()) + new_headers = [('Cache-Control', 'no-cache')] + unwanted_keys += ['Expires', 'Etag', 'Cache-Control'] + + for k, v in headers: + if k not in unwanted_keys: + new_headers.append((k, v)) + + start_response(status, new_headers) return self.app(environ, start_wrapped) class Root(object):