我将从服务器返回一个Webob.Response对象到http请求。服务器将一个BytesIO对象组合在一起。如何正确地将BytesIO对象附加到Webob.Response对象?
我试过:
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)没有运气,当我在客户端打印response.content时,它只是空的
我也试过:
return Response(self.file, '200 ok', content_type='text/html')但这会导致一个错误:
文件"/home/abdul/abdul/scripting-120218/local/lib/python2.7/site-packages/webob/response.py",第147行,在init self._headerlist.append中((‘Content’,str(len(Body) TypeError:类型为'_io.BytesIO‘的对象没有len()
发布于 2016-03-16 18:53:28
好吧,终于搞清楚了。你可以把这个传递给FileIter
app_iter = FileIter(BytesIO_Object.read())https://stackoverflow.com/questions/36043926
复制相似问题