Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filestream_range_iterator needed a __len()__ method #97

Open
1letter opened this issue Oct 19, 2020 · 1 comment
Open

filestream_range_iterator needed a __len()__ method #97

1letter opened this issue Oct 19, 2020 · 1 comment

Comments

@1letter
Copy link

1letter commented Oct 19, 2020

see: collective/wildcard.media#75

@1letter
Copy link
Author

1letter commented Oct 19, 2020

should the implemented interface changed from

@implementer(IStreamIterator)
class filestream_range_iterator(Iterable):

to

@implementer(IUnboundStreamIterator)
class filestream_range_iterator(Iterable):

because the WSGIResponse Object in Zope.ZPublisher.HTTPResponse check for IUnboundStreamIterator not for IStreamIterator

def setBody(self, body, title='', is_error=False, lock=None):
   # allow locking of the body in the same way as the status
   if self._locked_body:
       return

   if isinstance(body, IOBase):
       body.seek(0, 2)
       length = body.tell()
       body.seek(0)
       self.setHeader('Content-Length', '%d' % length)
       self.body = body
   elif IStreamIterator.providedBy(body):
       self.body = body
       super(WSGIResponse, self).setBody(b'', title, is_error)
   elif IUnboundStreamIterator.providedBy(body):
       self.body = body
       self._streaming = 1
       super(WSGIResponse, self).setBody(b'', title, is_error)
   else:
       super(WSGIResponse, self).setBody(body, title, is_error)

But i'm not so deep in this package, to answer this question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant