[Checkins] SVN: zope.publisher/trunk/ It turns out that some Web
servers (Paste for example) do not send the EOF
Stephan Richter
srichter at cosmos.phy.tufts.edu
Fri Jun 20 19:15:12 EDT 2008
Log message for revision 87610:
It turns out that some Web servers (Paste for example) do not send the EOF
character after the data has been transmitted and the read() of the
cached stream simply hangs if no expected content length has been specified.
Changed:
U zope.publisher/trunk/CHANGES.txt
U zope.publisher/trunk/setup.py
U zope.publisher/trunk/src/zope/publisher/http.py
U zope.publisher/trunk/src/zope/publisher/tests/test_http.py
-=-
Modified: zope.publisher/trunk/CHANGES.txt
===================================================================
--- zope.publisher/trunk/CHANGES.txt 2008-06-20 23:14:43 UTC (rev 87609)
+++ zope.publisher/trunk/CHANGES.txt 2008-06-20 23:15:11 UTC (rev 87610)
@@ -2,6 +2,16 @@
CHANGES
=======
+3.5.3 (2008-06-20)
+------------------
+
+Bugs fixed:
+
+- It turns out that some Web servers (Paste for example) do not send the EOF
+ character after the data has been transmitted and the read() of the cached
+ stream simply hangs if no expected content length has been specified.
+
+
3.5.2 (2008-04-06)
------------------
Modified: zope.publisher/trunk/setup.py
===================================================================
--- zope.publisher/trunk/setup.py 2008-06-20 23:14:43 UTC (rev 87609)
+++ zope.publisher/trunk/setup.py 2008-06-20 23:15:11 UTC (rev 87610)
@@ -24,8 +24,8 @@
"""
setup(name='zope.publisher',
- version = '3.6dev',
- url='http://cheeseshop.python.org/pypi/zope.publisher',
+ version = '3.5.3',
+ url='http://pypi.python.org/pypi/zope.publisher',
license='ZPL 2.1',
author='Zope Corporation and Contributors',
author_email='zope3-dev at zope.org',
Modified: zope.publisher/trunk/src/zope/publisher/http.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/http.py 2008-06-20 23:14:43 UTC (rev 87609)
+++ zope.publisher/trunk/src/zope/publisher/http.py 2008-06-20 23:15:11 UTC (rev 87610)
@@ -200,9 +200,10 @@
self.cacheStream = StringIO()
else:
self.cacheStream = TemporaryFile()
+ self.size = size and int(size) or -1
def getCacheStream(self):
- self.read()
+ self.read(self.size)
self.cacheStream.seek(0)
return self.cacheStream
@@ -224,8 +225,8 @@
data = self.stream.readlines(hint)
self.cacheStream.write(''.join(data))
return data
-
+
DEFAULT_PORTS = {'http': '80', 'https': '443'}
STAGGER_RETRIES = True
Modified: zope.publisher/trunk/src/zope/publisher/tests/test_http.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/tests/test_http.py 2008-06-20 23:14:43 UTC (rev 87609)
+++ zope.publisher/trunk/src/zope/publisher/tests/test_http.py 2008-06-20 23:15:11 UTC (rev 87610)
@@ -146,6 +146,27 @@
{'CONTENT_LENGTH': '',
'HTTP_CONTENT_LENGTH': ''})
+ def testWorkingWithNonClosingStreams(self):
+ # It turns out that some Web servers (Paste for example) do not send
+ # the EOF signal after the data has been transmitted and the read()
+ # simply hangs if no expected content length has been specified.
+ #
+ # In this test we simulate the hanging of the server by throwing an
+ # exception.
+ class ServerHung(Exception):
+ pass
+
+ class NonClosingStream(object):
+ def read(self, size=-1):
+ if size == -1:
+ raise ServerHung
+ return 'a'*size
+
+ stream = HTTPInputStream(NonClosingStream(), {'CONTENT_LENGTH': '10'})
+ self.assertEquals(stream.getCacheStream().read(), 'aaaaaaaaaa')
+ stream = HTTPInputStream(NonClosingStream(), {})
+ self.assertRaises(ServerHung, stream.getCacheStream)
+
class HTTPTests(unittest.TestCase):
_testEnv = {
More information about the Checkins
mailing list