[Checkins] SVN: Zope/trunk/ - Launchpad #267834: proper separation of HTTP header fields

Andreas Jung andreas at andreas-jung.com
Tue Sep 9 00:49:17 EDT 2008


Log message for revision 90980:
  
  - Launchpad #267834: proper separation of HTTP header fields   
    using CRLF as requested by RFC 2616.
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/OFS/tests/testRanges.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/functional.py
  U   Zope/trunk/lib/python/Testing/tests/test_makerequest.py
  U   Zope/trunk/lib/python/ZPublisher/HTTPResponse.py
  U   Zope/trunk/lib/python/ZPublisher/tests/testHTTPResponse.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt	2008-09-09 00:34:04 UTC (rev 90979)
+++ Zope/trunk/doc/CHANGES.txt	2008-09-09 04:49:14 UTC (rev 90980)
@@ -207,6 +207,9 @@
 
     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
 

Modified: Zope/trunk/lib/python/OFS/tests/testRanges.py
===================================================================
--- Zope/trunk/lib/python/OFS/tests/testRanges.py	2008-09-09 00:34:04 UTC (rev 90979)
+++ Zope/trunk/lib/python/OFS/tests/testRanges.py	2008-09-09 04:49:14 UTC (rev 90980)
@@ -102,7 +102,7 @@
 
         # 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
 

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/functional.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/functional.py	2008-09-09 00:34:04 UTC (rev 90979)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/functional.py	2008-09-09 04:49:14 UTC (rev 90980)
@@ -108,7 +108,7 @@
 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

Modified: Zope/trunk/lib/python/Testing/tests/test_makerequest.py
===================================================================
--- Zope/trunk/lib/python/Testing/tests/test_makerequest.py	2008-09-09 00:34:04 UTC (rev 90979)
+++ Zope/trunk/lib/python/Testing/tests/test_makerequest.py	2008-09-09 04:49:14 UTC (rev 90980)
@@ -51,7 +51,7 @@
         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):

Modified: Zope/trunk/lib/python/ZPublisher/HTTPResponse.py
===================================================================
--- Zope/trunk/lib/python/ZPublisher/HTTPResponse.py	2008-09-09 00:34:04 UTC (rev 90979)
+++ Zope/trunk/lib/python/ZPublisher/HTTPResponse.py	2008-09-09 04:49:14 UTC (rev 90980)
@@ -254,7 +254,7 @@
         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 @@
         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 @@
         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 @@
         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):
         """\

Modified: Zope/trunk/lib/python/ZPublisher/tests/testHTTPResponse.py
===================================================================
--- Zope/trunk/lib/python/ZPublisher/tests/testHTTPResponse.py	2008-09-09 00:34:04 UTC (rev 90979)
+++ Zope/trunk/lib/python/ZPublisher/tests/testHTTPResponse.py	2008-09-09 04:49:14 UTC (rev 90980)
@@ -72,10 +72,10 @@
         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()



More information about the Checkins mailing list