From 2e30144d77340b05cc059f2d06c2b79eab3b36c3 Mon Sep 17 00:00:00 2001 From: pjenvey Date: Mon, 26 Jun 2006 02:03:39 +0000 Subject: o revised the r5420 patch to be specific to the _IfModifiedSince header o added a test to reproduce ticket #114 --- paste/httpheaders.py | 14 ++++++++++---- tests/test_fileapp.py | 7 +++++-- 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 "" == 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 "" == repr(res) + res = harness.get("/",headers={'if-modified-since': last_modified + \ + '; length=1506'}) assert "" == repr(res) res = harness.get("/",status=400, headers={'if-modified-since': 'garbage'}) -- cgit v1.2.1