diff --git a/src/ZPublisher/WSGIPublisher.py b/src/ZPublisher/WSGIPublisher.py index 5f85dbb1e8cb2397573a4f063633193c11fcb8e8..c72ed039458a4afc1b9f912f4ff694bd20cf4de0 100644 --- a/src/ZPublisher/WSGIPublisher.py +++ b/src/ZPublisher/WSGIPublisher.py @@ -282,7 +282,7 @@ def publish_module(environ, start_response, body = response.body - if isinstance(body, file) or IStreamIterator.providedBy(body): + if isinstance(body, file) or IUnboundStreamIterator.providedBy(body): result = body else: # If somebody used response.write, that data will be in the diff --git a/src/ZPublisher/tests/test_WSGIPublisher.py b/src/ZPublisher/tests/test_WSGIPublisher.py index 6e045017089646daac3092098d1466415955061e..d876689b965c8df124b0221b04e75ac0fa9560af 100644 --- a/src/ZPublisher/tests/test_WSGIPublisher.py +++ b/src/ZPublisher/tests/test_WSGIPublisher.py @@ -447,6 +447,31 @@ class Test_publish_module(unittest.TestCase): app_iter = self._callFUT(environ, start_response, _publish) self.assertTrue(app_iter is body) + def test_response_is_unboundstream(self): + from ZPublisher.Iterators import IUnboundStreamIterator + from zope.interface import implements + + class test_unboundstreamiterator: + implements(IUnboundStreamIterator) + data = "hello" + done = 0 + + def next(self): + if not self.done: + self.done = 1 + return self.data + raise StopIteration + + _response = DummyResponse() + _response._status = '200 OK' + body = _response.body = test_unboundstreamiterator() + environ = self._makeEnviron() + start_response = DummyCallable() + _publish = DummyCallable() + _publish._result = _response + app_iter = self._callFUT(environ, start_response, _publish) + self.assertTrue(app_iter is body) + def test_request_closed_when_tm_middleware_not_active(self): environ = self._makeEnviron() start_response = DummyCallable()