Log message for revision 67957:
  Five.testbrowser did not do the munging of the headers that the zope2 HTTP 
response did. It was also inconsistent with Zope3 testbrowser tests. Fix that.

Changed:
  U   Products.Five/trunk/testbrowser.py
  U   Products.Five/trunk/tests/test_testbrowser.py

-=-
Modified: Products.Five/trunk/testbrowser.py
===================================================================
--- Products.Five/trunk/testbrowser.py  2006-05-03 23:55:20 UTC (rev 67956)
+++ Products.Five/trunk/testbrowser.py  2006-05-04 00:11:01 UTC (rev 67957)
@@ -30,7 +30,20 @@
         real_response = self.response._response
         status = real_response.getStatus()
         reason = zope.publisher.http.status_reasons[real_response.status]
-        headers = real_response.headers.items()
+        headers = []
+        # Convert header keys to camel case. This is basically a copy
+        # paste from ZPublisher.HTTPResponse
+        for key, val in real_response.headers.items():
+            if key.lower() == key:
+                # only change non-literal header names
+                key = "%s%s" % (key[:1].upper(), key[1:])
+                start = 0
+                l = key.find('-',start)
+                while l >= start:
+                    key = "%s-%s%s" % (key[:l],key[l+1:l+2].upper(),key[l+2:])
+                    start = l + 1
+                    l = key.find('-', start)
+            headers.append((key, val))
         # get the cookies, breaking them into tuples for sorting
         cookies = [(c[:10], c[12:]) for c in real_response._cookie_list()]
         headers.extend(cookies)

Modified: Products.Five/trunk/tests/test_testbrowser.py
===================================================================
--- Products.Five/trunk/tests/test_testbrowser.py       2006-05-03 23:55:20 UTC 
(rev 67956)
+++ Products.Five/trunk/tests/test_testbrowser.py       2006-05-04 00:11:01 UTC 
(rev 67957)
@@ -54,6 +54,29 @@
         True
     """
 
+def doctest_camel_case_headers():
+    """Make sure that the headers come out in camel case.
+
+    Some setup:
+
+        >>> from Products.Five.tests.test_testbrowser import CookieStub
+        >>> self.folder._setObject('stub', CookieStub())
+        'stub'
+
+    The Zope2 response mungs headers so they come out in camel case we should
+    do the same. This is also more consistent with the Zope3 testbrowser tests.
+    We will test a few:
+
+        >>> from Products.Five.testbrowser import Browser
+        >>> browser = Browser()
+        >>> browser.open('http://localhost/test_folder_1_/stub')
+        >>> 'Content-Length: ' in str(browser.headers)
+        True
+        >>> 'Content-Type: ' in str(browser.headers)
+        True
+    """
+
+
 def test_suite():
     return unittest.TestSuite((
             FunctionalDocTestSuite(),

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to