Commits

Anonymous committed ed3a79b

Change cookie expires date

Comments (0)

Files changed (2)

 
 .. contents::
 
+svn trunk
+---------
+
+* Change formatting of cookie expires, to use the more traditional
+  format ``Wed, 5-May-2001 15:34:10 GMT`` (dashes instead of spaces).
+  Browsers should deal with either format, but some other code expects
+  dashes.
+
 0.9.1
 -----
 

webob/__init__.py

             "You must pass in a datetime, date, time tuple, or integer object, not %r" % dt)
     return formatdate(dt)
 
+def _serialize_cookie_date(dt):
+    if dt is None:
+        return None
+    if isinstance(dt, unicode):
+        dt = dt.encode('ascii')
+    if isinstance(dt, timedelta):
+        dt = datetime.now() + dt
+    if isinstance(dt, (datetime, date)):
+        dt = dt.timetuple()
+    return time.strftime('%a, %d-%b-%Y %H:%M:%S GMT', dt)
+
 def _parse_date_delta(value):
     """
     like _parse_date, but also handle delta seconds
         if isinstance(expires, timedelta):
             expires = datetime.utcnow() + expires
         if isinstance(expires, datetime):
-            expires = '"'+_serialize_date(expires)+'"'
+            expires = '"'+_serialize_cookie_date(expires)+'"'
         for var_name, var_value in [
             ('max_age', max_age),
             ('path', path),