【发布时间】:2016-03-16 18:21:05
【问题描述】:
我将 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')
但这会引发错误:
init 中的文件“/home/abdul/abdul/scripting-120218/local/lib/python2.7/site-packages/webob/response.py”,第 147 行 self._headerlist.append(('Content-Length', str(len(body)))) TypeError: '_io.BytesIO' 类型的对象没有 len()
【问题讨论】: