summaryrefslogtreecommitdiff
path: root/paste/urlparser.py
diff options
context:
space:
mode:
authorbbangert <devnull@localhost>2006-01-18 22:26:41 +0000
committerbbangert <devnull@localhost>2006-01-18 22:26:41 +0000
commit23a2c90408eda5cdc1170e8c94624e8f0c93875f (patch)
tree82498d508e82fad0247d1a14663b31d17698b8a2 /paste/urlparser.py
parent47c5d974199a85af11bce55a5d2f1b7933a8ee0d (diff)
downloadpaste-23a2c90408eda5cdc1170e8c94624e8f0c93875f.tar.gz
Using ETag's for browser-side HTTP 1.1 caching when available for static content. If found, throwing the 304 with the ETag early, before fileapp creation/call, for efficiency.
Diffstat (limited to 'paste/urlparser.py')
-rw-r--r--paste/urlparser.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/paste/urlparser.py b/paste/urlparser.py
index 671bb8c..4af20ad 100644
--- a/paste/urlparser.py
+++ b/paste/urlparser.py
@@ -14,6 +14,7 @@ import fileapp
from paste.util import import_string
from paste.deploy import converters
import httpexceptions
+from httpheaders import ETAG
class NoDefault:
pass
@@ -433,6 +434,15 @@ class StaticURLParser(object):
return self.__class__(full)(environ, start_response)
if environ.get('PATH_INFO') and environ.get('PATH_INFO') != '/':
return self.error_extra_path(environ, start_response)
+ if_none_match = environ.get('HTTP_IF_NONE_MATCH')
+ if if_none_match:
+ mytime = os.stat(full).st_mtime
+ if str(mytime) == if_none_match:
+ headers = []
+ ETAG.update(headers, mytime)
+ start_response('304 Not Modified',headers)
+ return [''] # empty body
+
return fileapp.FileApp(full)(environ, start_response)
def add_slash(self, environ, start_response):