[Zope-Checkins] SVN: Zope/trunk/ Merge [121447] to trunk - ZPublisher: HTTPResponse.appendHeader now keeps header values to a single

Laurence Rowe l at lrowe.co.uk
Tue Apr 19 11:05:27 EDT 2011


Log message for revision 121448:
  Merge [121447] to trunk - ZPublisher: HTTPResponse.appendHeader now keeps header values to a single
  line by default to avoid causing problems for proxy servers which do not
  correctly handle multi-line headers. (Merged from 2.13 branch.)
  

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

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst	2011-04-19 15:01:30 UTC (rev 121447)
+++ Zope/trunk/doc/CHANGES.rst	2011-04-19 15:05:26 UTC (rev 121448)
@@ -32,6 +32,10 @@
 Features Added
 ++++++++++++++
 
+- ZPublisher: HTTPResponse.appendHeader now keeps header values to a single
+  line by default to avoid causing problems for proxy servers which do not
+  correctly handle multi-line headers. (Merged from 2.13 branch.)
+
 - Add preliminary IPv6 support to ZServer.
 
 - ZPublisher: If `IBrowserPage` is provided by a view, form input is decoded.

Modified: Zope/trunk/src/ZPublisher/HTTPResponse.py
===================================================================
--- Zope/trunk/src/ZPublisher/HTTPResponse.py	2011-04-19 15:01:30 UTC (rev 121447)
+++ Zope/trunk/src/ZPublisher/HTTPResponse.py	2011-04-19 15:05:26 UTC (rev 121448)
@@ -338,7 +338,7 @@
             name = literal and name or key
             self.headers[name] = value
 
-    def appendHeader(self, name, value, delimiter=","):
+    def appendHeader(self, name, value, delimiter=", "):
         """ Append a value to an HTTP return header.
 
         Set an HTTP return header "name" with value "value",
@@ -353,7 +353,7 @@
         headers = self.headers
         if headers.has_key(name):
             h = headers[name]
-            h = "%s%s\r\n\t%s" % (h, delimiter, value)
+            h = "%s%s%s" % (h, delimiter, value)
         else:
             h = value
         self.setHeader(name,h, scrubbed=True)

Modified: Zope/trunk/src/ZPublisher/tests/testHTTPResponse.py
===================================================================
--- Zope/trunk/src/ZPublisher/tests/testHTTPResponse.py	2011-04-19 15:01:30 UTC (rev 121447)
+++ Zope/trunk/src/ZPublisher/tests/testHTTPResponse.py	2011-04-19 15:05:26 UTC (rev 121448)
@@ -445,13 +445,13 @@
         response = self._makeOne()
         response.setHeader('foo', 'bar')
         response.appendHeader('foo', 'foo')
-        self.assertEqual(response.headers.get('foo'), 'bar,\r\n\tfoo')
+        self.assertEqual(response.headers.get('foo'), 'bar, foo')
 
     def test_appendHeader_w_existing_case_insenstative(self):
         response = self._makeOne()
         response.setHeader('xxx', 'bar')
         response.appendHeader('XXX', 'foo')
-        self.assertEqual(response.headers.get('xxx'), 'bar,\r\n\tfoo')
+        self.assertEqual(response.headers.get('xxx'), 'bar, foo')
 
     def test_appendHeader_drops_CRLF(self):
         # RFC2616 disallows CRLF in a header value.



More information about the Zope-Checkins mailing list