summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpjenvey <devnull@localhost>2006-06-26 02:03:39 +0000
committerpjenvey <devnull@localhost>2006-06-26 02:03:39 +0000
commit2e30144d77340b05cc059f2d06c2b79eab3b36c3 (patch)
tree5af06ff1d66c18aba0e43ff77548dd6b2041323b
parent1a58c400ad3a218809d5035ee652a9de4f149ea8 (diff)
downloadpaste-2e30144d77340b05cc059f2d06c2b79eab3b36c3.tar.gz
o revised the r5420 patch to be specific to the _IfModifiedSince header
o added a test to reproduce ticket #114
-rw-r--r--paste/httpheaders.py14
-rw-r--r--tests/test_fileapp.py7
2 files changed, 15 insertions, 6 deletions
diff --git a/paste/httpheaders.py b/paste/httpheaders.py
index 13fef83..e5bb85a 100644
--- a/paste/httpheaders.py
+++ b/paste/httpheaders.py
@@ -609,10 +609,7 @@ class _DateHeader(_SingleValueHeader):
value = self.__call__(*args, **kwargs)
if value:
try:
- # Split on ';' incase the date header includes extra attributes.
- # E.g. IE 6 is known to send:
- # If-Modified-Since: Sun, 25 Jun 2006 20:36:35 GMT; length=1506
- return mktime_tz(parsedate_tz(value.split(';')[0]))
+ return mktime_tz(parsedate_tz(value))
except TypeError:
raise HTTPBadRequest((
"Received an ill-formed timestamp for %s: %s\r\n") %
@@ -863,6 +860,15 @@ class _IfModifiedSince(_DateHeader):
If-Modified-Since, RFC 2616 section 14.25
"""
version = '1.0'
+
+ def __call__(self, *args, **kwargs):
+ """
+ Split the value on ';' incase the header includes extra attributes. E.g.
+ IE 6 is known to send:
+ If-Modified-Since: Sun, 25 Jun 2006 20:36:35 GMT; length=1506
+ """
+ return _DateHeader.__call__(self, *args, **kwargs).split(';')[0]
+
def parse(self, *args, **kwargs):
value = _DateHeader.parse(self, *args, **kwargs)
if value and value > now():
diff --git a/tests/test_fileapp.py b/tests/test_fileapp.py
index c3188e3..039e2be 100644
--- a/tests/test_fileapp.py
+++ b/tests/test_fileapp.py
@@ -69,8 +69,11 @@ def test_modified():
harness = TestApp(DataApp('mycontent'))
res = harness.get("/")
assert "<Response 200 OK 'mycontent'>" == repr(res)
- res = harness.get("/",headers={'if-modified-since':
- res.header('last-modified')})
+ last_modified = res.header('last-modified')
+ res = harness.get("/",headers={'if-modified-since': last_modified})
+ assert "<Response 304 Not Modified ''>" == repr(res)
+ res = harness.get("/",headers={'if-modified-since': last_modified + \
+ '; length=1506'})
assert "<Response 304 Not Modified ''>" == repr(res)
res = harness.get("/",status=400,
headers={'if-modified-since': 'garbage'})