I'm returning a Webob.Response object from my server to http request. The server puts together a BytesIO object. How can I correctly attach the BytesIO object to the Webob.Response object?
I tried:
app_iter = FileIter(BytesIO_Object)
return Response(
app_iter=app_iter,
last_modified=last_modified,
content_length=content_length,
content_type=content_type,
content_encoding=content_encoding,
content_disposition=content_disposition,
accept_ranges=accept_ranges,
conditional_response=True)
no luck, when I print response.content
on the client side, its just empty
I also tried:
return Response(self.file, '200 ok', content_type='text/html')
but that throws an error:
File "/home/abdul/abdul/scripting-120218/local/lib/python2.7/site-packages/webob/response.py", line 147, in init self._headerlist.append(('Content-Length', str(len(body)))) TypeError: object of type '_io.BytesIO' has no len()
ok finally figured it out. You can to pass this to FileIter
app_iter = FileIter(BytesIO_Object.read())