You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/12/16 18:26:17 UTC

git commit: [#6942] separate etag and last_modified params in serve_file

Updated Branches:
  refs/heads/tv/6942 699baceca -> eb8992ac1


[#6942] separate etag and last_modified params in serve_file


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/eb8992ac
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/eb8992ac
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/eb8992ac

Branch: refs/heads/tv/6942
Commit: eb8992ac1ae2d0336bf8a943be5212363149da2f
Parents: 699bace
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon Dec 16 17:11:39 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Dec 16 17:11:39 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/static.py | 2 +-
 Allura/allura/lib/utils.py          | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/eb8992ac/Allura/allura/controllers/static.py
----------------------------------------------------------------------
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 @@ class NewForgeController(object):
         """
         css, md5 = g.tool_icon_css
         return utils.serve_file(StringIO(css), 'tool_icon_css', 'text/css',
-                last_modified=md5)
+                etag=md5)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/eb8992ac/Allura/allura/lib/utils.py
----------------------------------------------------------------------
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 @@ def take_while_true(source):
         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))