[Zope-Checkins] SVN: Zope/trunk/ `setHeader('Set-Cookie', ...)` special-casing can die

Martijn Pieters mj at zopatista.com
Thu Oct 13 08:18:33 EST 2011


Log message for revision 123087:
  `setHeader('Set-Cookie', ...)` special-casing can die
  
  Use the cookie APIs or addHeader instead.
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/ZPublisher/HTTPResponse.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst	2011-10-13 09:46:28 UTC (rev 123086)
+++ Zope/trunk/doc/CHANGES.rst	2011-10-13 13:18:32 UTC (rev 123087)
@@ -50,6 +50,11 @@
 Restructuring
 +++++++++++++
 
+- Removed the special handling of `Set-Cookie` headers in
+  `HTTPResponse.setHeader`. Use the `setCookie`/`appendCookie`/`expireCookie`
+  methods instead, or if low-level control is needed, use `addHeader` instead
+  to get the exact same effect.
+
 - Removed the `App.version_txt.getZopeVersion` API, you can use
   ``pkg_resources.get_distribution('Zope2').version`` instead.
 

Modified: Zope/trunk/src/ZPublisher/HTTPResponse.py
===================================================================
--- Zope/trunk/src/ZPublisher/HTTPResponse.py	2011-10-13 09:46:28 UTC (rev 123086)
+++ Zope/trunk/src/ZPublisher/HTTPResponse.py	2011-10-13 13:18:32 UTC (rev 123087)
@@ -330,13 +330,8 @@
         if not scrubbed:
             name, value = _scrubHeader(name, value)
         key = name.lower()
-        # The following is crazy, given that we have APIs for cookies.
-        # Special behavior will go away in Zope 2.13
-        if key == 'set-cookie':  
-            self.accumulated_headers.append((name, value))
-        else:
-            name = literal and name or key
-            self.headers[name] = value
+        name = literal and name or key
+        self.headers[name] = value
 
     def appendHeader(self, name, value, delimiter=", "):
         """ Append a value to an HTTP return header.



More information about the Zope-Checkins mailing list