Commits

pjenvey  committed 22223c9

o revised the r5420 patch to be specific to the _IfModifiedSince header
o added a test to reproduce ticket #114

  • Participants
  • Parent commits 887fd8a

Comments (0)

Files changed (2)

File paste/httpheaders.py

         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") %
     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():

File tests/test_fileapp.py

     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'})