Commits

Sergey Schetinin committed 5301de8

make sure that resp.unset_cookie does not merge multiple cookie headers into one

Comments (0)

Files changed (3)

tests/test_response.txt

     ['test2=value2-replace; Path=/']
 
 
+    >>> r = Response()
+    >>> r.set_cookie('x', 'x')
+    >>> r.set_cookie('y', 'y')
+    >>> r.set_cookie('z', 'z')
+    >>> r.headers.getall('set-cookie')
+    ['x=x; Path=/', 'y=y; Path=/', 'z=z; Path=/']
+    >>> r.unset_cookie('y')
+    >>> r.headers.getall('set-cookie')
+    ['x=x; Path=/', 'z=z; Path=/']
+
+
 Most headers are available in a parsed getter/setter form through
 properties:
 
         dict.__setitem__(self, key, Morsel(key, val))
 
     def serialize(self, full=True):
-        return ', '.join(m.serialize(full) for _,m in sorted(self.items()))
+        return ', '.join(m.serialize(full) for m in self.values())
+
+    def values(self):
+        return [m for _,m in sorted(self.items())]
 
     __str__ = serialize
 

webob/response.py

         if key in cookies:
             del cookies[key]
             del self.headers['Set-Cookie']
-            if cookies:
-                self.headerlist.append(('Set-Cookie', str(cookies)))
+            for m in cookies.values():
+                self.headerlist.append(('Set-Cookie', str(m)))
         elif strict:
             raise KeyError("No cookie has been set with the name %r" % key)