[Checkins] SVN: zope.publisher/branches/3.4/src/zope/publisher/tests/test_http.py add missing test for backport fix

Michael Haubenwallner michael at d2m.at
Fri Jun 26 17:34:23 EDT 2009


Log message for revision 101294:
  add missing test for backport fix

Changed:
  U   zope.publisher/branches/3.4/src/zope/publisher/tests/test_http.py

-=-
Modified: zope.publisher/branches/3.4/src/zope/publisher/tests/test_http.py
===================================================================
--- zope.publisher/branches/3.4/src/zope/publisher/tests/test_http.py	2009-06-26 21:09:24 UTC (rev 101293)
+++ zope.publisher/branches/3.4/src/zope/publisher/tests/test_http.py	2009-06-26 21:34:23 UTC (rev 101294)
@@ -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