Commit c0f05183 authored by Gerhard Weis's avatar Gerhard Weis

check most specific interface first (IStreamIterator before IUnboundStreamIterator)

parent 9c5e0cfd
...@@ -137,12 +137,12 @@ class WSGIResponse(HTTPResponse): ...@@ -137,12 +137,12 @@ class WSGIResponse(HTTPResponse):
body.seek(0) body.seek(0)
self.setHeader('Content-Length', '%d' % length) self.setHeader('Content-Length', '%d' % length)
self.body = body self.body = body
elif IUnboundStreamIterator.providedBy(body): elif IStreamIterator.providedBy(body):
self.body = body self.body = body
self._streaming = 1
HTTPResponse.setBody(self, '', title, is_error) HTTPResponse.setBody(self, '', title, is_error)
elif IStreamIterator.providedBy(body): elif IUnboundStreamIterator.providedBy(body):
self.body = body self.body = body
self._streaming = 1
HTTPResponse.setBody(self, '', title, is_error) HTTPResponse.setBody(self, '', title, is_error)
else: else:
HTTPResponse.setBody(self, body, title, is_error) HTTPResponse.setBody(self, body, title, is_error)
......
...@@ -157,6 +157,7 @@ class WSGIResponseTests(unittest.TestCase): ...@@ -157,6 +157,7 @@ class WSGIResponseTests(unittest.TestCase):
response.setBody(body) response.setBody(body)
response.finalize() response.finalize()
self.assertTrue(body is response.body) self.assertTrue(body is response.body)
self.assertEqual(response._streaming, 1)
def test_setBody_IStreamIterator(self): def test_setBody_IStreamIterator(self):
from ZPublisher.Iterators import IStreamIterator from ZPublisher.Iterators import IStreamIterator
...@@ -182,6 +183,7 @@ class WSGIResponseTests(unittest.TestCase): ...@@ -182,6 +183,7 @@ class WSGIResponseTests(unittest.TestCase):
response.setBody(body) response.setBody(body)
response.finalize() response.finalize()
self.assertTrue(body is response.body) self.assertTrue(body is response.body)
self.assertEqual(response._streaming, 0)
#def test___str__already_wrote_not_chunking(self): #def test___str__already_wrote_not_chunking(self):
# response = self._makeOne() # response = self._makeOne()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment