Commit ded69662 authored by Andreas Jung's avatar Andreas Jung

- Launchpad #267834: proper separation of HTTP header fields

  using CRLF as requested by RFC 2616.
parent fa0e693a
......@@ -207,6 +207,9 @@ Zope Changes
Bugs Fixed
- Launchpad #267834: proper separation of HTTP header fields
using CRLF as requested by RFC 2616.
- Launchpad #267545: DateTime(DateTime()) now preserves the
correct hour
......
......@@ -102,7 +102,7 @@ class TestRequestRange(unittest.TestCase):
# Chop off any printed headers (only when response.write was used)
if body:
body = string.split(body, '\n\n', 1)[1]
body = string.split(body, '\r\n\r\n', 1)[1]
return body + rv
......
......@@ -108,7 +108,7 @@ class Functional(sandbox.Sandboxed):
class ResponseWrapper:
'''Decorates a response object with additional introspective methods.'''
_bodyre = re.compile('^$^\n(.*)', re.MULTILINE | re.DOTALL)
_bodyre = re.compile('\r\n\r\n(.*)', re.MULTILINE | re.DOTALL)
def __init__(self, response, outstream, path):
self._response = response
......
......@@ -51,7 +51,7 @@ class MakerequestTests(unittest.TestCase):
item.REQUEST.RESPONSE.write('aaa')
out.seek(0)
written = out.read()
self.failUnless(written.startswith('Status: 200 OK\n'))
self.failUnless(written.startswith('Status: 200 OK\r\n'))
self.failUnless(written.endswith('\naaa'))
def test_environ(self):
......
......@@ -254,7 +254,7 @@ class HTTPResponse(BaseResponse):
key = name.lower()
if accumulate_header(key):
self.accumulated_headers = (
"%s%s: %s\n" % (self.accumulated_headers, name, value))
"%s%s: %s\r\n" % (self.accumulated_headers, name, value))
return
name = literal and name or key
self.headers[name] = value
......@@ -278,7 +278,7 @@ class HTTPResponse(BaseResponse):
name = str(name)
value = str(value)
self.accumulated_headers = (
"%s%s: %s\n" % (self.accumulated_headers, name, value))
"%s%s: %s\r\n" % (self.accumulated_headers, name, value))
__setitem__ = setHeader
......@@ -591,7 +591,7 @@ class HTTPResponse(BaseResponse):
headers = self.headers
if headers.has_key(name):
h = headers[name]
h = "%s%s\n\t%s" % (h,delimiter,value)
h = "%s%s\r\n\t%s" % (h,delimiter,value)
else:
h = value
self.setHeader(name,h)
......@@ -893,7 +893,7 @@ class HTTPResponse(BaseResponse):
if self.cookies:
headersl = headersl+self._cookie_list()
headersl[len(headersl):] = [self.accumulated_headers, body]
return '\n'.join(headersl)
return '\r\n'.join(headersl)
def write(self,data):
"""\
......
......@@ -72,10 +72,10 @@ class HTTPResponseTests(unittest.TestCase):
response = self._makeOne()
response.setHeader('foo', 'bar')
response.appendHeader('foo', 'foo')
self.assertEqual(response.headers.get('foo'), 'bar,\n\tfoo')
self.assertEqual(response.headers.get('foo'), 'bar,\r\n\tfoo')
response.setHeader('xxx', 'bar')
response.appendHeader('XXX', 'foo')
self.assertEqual(response.headers.get('xxx'), 'bar,\n\tfoo')
self.assertEqual(response.headers.get('xxx'), 'bar,\r\n\tfoo')
def test_setHeader(self):
response = self._makeOne()
......
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