[#6942] separate etag and last_modified params in serve_file
diff --git a/Allura/allura/controllers/static.py b/Allura/allura/controllers/static.py
index 53b8be5..dd8c37f 100644
--- a/Allura/allura/controllers/static.py
+++ b/Allura/allura/controllers/static.py
@@ -49,4 +49,4 @@
"""
css, md5 = g.tool_icon_css
return utils.serve_file(StringIO(css), 'tool_icon_css', 'text/css',
- last_modified=md5)
+ etag=md5)
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index 3e92f46..d35b17e 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -478,10 +478,12 @@
x = source()
-def serve_file(fp, filename, content_type, last_modified=None, cache_expires=None, size=None, embed=True):
+def serve_file(fp, filename, content_type, last_modified=None, cache_expires=None, size=None, embed=True, etag=None):
'''Sets the response headers and serves as a wsgi iter'''
- if filename and last_modified:
- etag_cache(u'{0}?{1}'.format(filename, last_modified).encode('utf-8'))
+ if not etag and filename and last_modified:
+ etag = u'{0}?{1}'.format(filename, last_modified).encode('utf-8')
+ if etag:
+ etag_cache(etag)
pylons.response.headers['Content-Type'] = ''
pylons.response.content_type = content_type.encode('utf-8')
pylons.response.cache_expires = cache_expires or asint(tg.config.get('files_expires_header_secs', 60 * 60))