Commit a984a950 authored by Laurence Rowe's avatar Laurence Rowe

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.)
parent b2d1e288
......@@ -32,6 +32,10 @@ Bugs Fixed
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.
......
......@@ -338,7 +338,7 @@ class HTTPResponse(BaseResponse):
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 @@ class HTTPResponse(BaseResponse):
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)
......
......@@ -445,13 +445,13 @@ class HTTPResponseTests(unittest.TestCase):
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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment