如何将响应内容长度设置为无限 [英] How to set response Content-Length to infinite
问题描述
我尝试在 web2py
框架中创建一个应用程序.默认情况下,web2py
服务器具有 Transfer-Encoding: Chunked
响应标头,但在这种情况下,当目标远程 Web 应用程序向我的应用程序发送 GET 请求时,它只能获取第一个字符串来自请求页面的文本(来自页面上显示的文件内容).如果使用 Content-Length
代替,例如,值为 1000 它将从页面中获取 1000 字节的数据......但是如果我希望以大量数据进行响应,如何设置 Content-Length
参数为无穷大或按文件(如 here 但使用 web2py
语法而不是 php
)?
如果您通过内置开发服务器提供 web2py 并通过 Expose
功能,然后文件将通过分块传输编码提供.>
但是,如果您改为使用 response.stream
提供文件,Content-Length 标头将自动设置.
I try to create an application in web2py
framework. By default web2py
server has Transfer-Encoding: Chunked
header for response, but in that case when target remote web application sends GET request to my app it could get only first string of text from requested page (from file's content that displayed on page). If to use Content-Length
instead, for example, with value of 1000 it will get 1000 bytes of data from page... But if I expect to response with huge range of data, how to set Content-Length
parameter to infinity or by file (like here but with web2py
syntax instead of php
)?
If you are serving web2py via the built-in development server and serving files via the Expose
functionality, then the files will be served via chunked transfer encoding.
However, if you instead use response.stream
to serve files, the Content-Length header will be set automatically.
这篇关于如何将响应内容长度设置为无限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!