[Erp5-report] r31449 leonardo - /erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Dec 24 00:22:10 CET 2009
Author: leonardo
Date: Thu Dec 24 00:22:10 2009
New Revision: 31449
URL: http://svn.erp5.org?rev=31449&view=rev
Log:
Fix header/body parsing in ResponseWrapper.getBody()
Zope 2.12 now correctly outputs response header linebreaks with \r\n
instead of just \n, including the double line-break in the header/body
separator.
Adjusted the regular expression and simplified the body parsing logic in
Products.ERP5Type.tests.ERP5TypeTestCase.ResponseWrapper.getBody()
Modified:
erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
Modified: erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py?rev=31449&r1=31448&r2=31449&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py [utf8] Thu Dec 24 00:22:10 2009
@@ -1071,7 +1071,7 @@
class ResponseWrapper:
'''Decorates a response object with additional introspective methods.'''
- _bodyre = re.compile('^$^\n(.*)', re.MULTILINE | re.DOTALL)
+ _headers_separator_re = re.compile('(?:\r?\n){2}')
def __init__(self, response, outstream, path):
self._response = response
@@ -1087,10 +1087,13 @@
def getBody(self):
'''Returns the page body, i.e. the output par headers.'''
- body = self._bodyre.search(self.getOutput())
- if body is not None:
- body = body.group(1)
- return body
+ output = self.getOutput()
+ try:
+ headers, body = self._headers_separator_re.split(output, 1)
+ return body
+ except ValueError:
+ # not enough values to unpack: no body
+ return None
def getPath(self):
'''Returns the path used by the request.'''
More information about the Erp5-report
mailing list