[Zope-Checkins] SVN: Zope/trunk/src/ZServer/ fixed accumulated_headers not appending to headers correctly. closes #599378
Nathan Van Gheem
vangheem at gmail.com
Wed Aug 4 09:05:36 EDT 2010
Log message for revision 115436:
fixed accumulated_headers not appending to headers correctly. closes #599378
Changed:
U Zope/trunk/src/ZServer/HTTPResponse.py
U Zope/trunk/src/ZServer/tests/test_responses.py
-=-
Modified: Zope/trunk/src/ZServer/HTTPResponse.py
===================================================================
--- Zope/trunk/src/ZServer/HTTPResponse.py 2010-08-04 12:05:10 UTC (rev 115435)
+++ Zope/trunk/src/ZServer/HTTPResponse.py 2010-08-04 13:05:35 UTC (rev 115436)
@@ -119,11 +119,7 @@
self._chunking = 1
headers = headers.items()
- for line in self.accumulated_headers:
- if line[0] == '\t':
- headers[-1][1] += '\n' + line
- continue
- headers.append(line.split(': ', 1))
+ headers.extend(self.accumulated_headers)
for key, val in headers:
if key.lower() == key:
Modified: Zope/trunk/src/ZServer/tests/test_responses.py
===================================================================
--- Zope/trunk/src/ZServer/tests/test_responses.py 2010-08-04 12:05:10 UTC (rev 115435)
+++ Zope/trunk/src/ZServer/tests/test_responses.py 2010-08-04 13:05:35 UTC (rev 115436)
@@ -111,9 +111,8 @@
'Title-Cased': 'bar',
'mixed-CasED': 'spam',
'multilined': 'eggs\n\tham'}
- response.accumulated_headers = ['foo-bar: bar',
- '\tbaz',
- 'Foo-bar: monty']
+ response.accumulated_headers = [('foo-bar', 'bar'),
+ ('Foo-bar', 'monty')]
response.cookies = dict(foo=dict(value='bar'))
response.body = 'A body\nwith multiple lines\n'
@@ -124,13 +123,14 @@
self.assertTrue(headers.startswith('HTTP/1.0 200 OK\r\n'))
- # 15 header lines all delimited by \r\n
+ # 14 header lines all delimited by \r\n
self.assertEqual(
['\n' in line for line in headers.split('\r\n')],
- 15 * [False])
-
+ 14 * [False])
+
self.assertTrue('Multilined: eggs\r\n\tham\r\n' in headers)
- self.assertTrue('Foo-Bar: bar\r\n\tbaz\r\n' in headers)
+ self.assertTrue('Foo-bar: monty\r\n' in headers)
+ self.assertTrue('Foo-Bar: bar\r\n' in headers)
def _assertResponsesAreEqual(self, got, expected):
got = got.split('\r\n')
@@ -273,6 +273,12 @@
'',
''))
+ def test_uses_accumulated_headers_correctly(self):
+ response = self._makeOne()
+ response.setStatus(304)
+ response.addHeader('foo', 'bar')
+ self.assertTrue('Foo: bar' in str(response))
+
class _Reporter(object):
def __init__(self): self.events = []
def __call__(self, event): self.events.append(event)
More information about the Zope-Checkins
mailing list