Commit 4aadd74e authored by Nathan Van Gheem's avatar Nathan Van Gheem

fixed accumulated_headers not appending to headers correctly. closes #599378

parent 7b76e467
......@@ -119,11 +119,7 @@ class ZServerHTTPResponse(HTTPResponse):
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:
......
......@@ -111,9 +111,8 @@ class ZServerHTTPResponseTestCase(unittest.TestCase):
'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 @@ class ZServerHTTPResponseTestCase(unittest.TestCase):
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 @@ class ZServerHTTPResponseTestCase(unittest.TestCase):
'',
''))
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)
......
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