问题描述
我正在使用Django,mod_wsgi和Apache.当我以StreamingHttpResponse的形式进行响应并返回时,在响应中设置了Transfer-Encoding:chunked头.但是,当我将Content-Length标头添加到资源库中时,Transfer-Encoding标头被删除,只有Content-Length标头存在.
I am using Django, mod_wsgi and Apache.When I make a response as StreamingHttpResponse and return, Transfer-Encoding: chunked header is set in the response.But when I add the Content-Length header to the resposne, Transfer-Encoding header is removed and only the Content-Length header exists.
谁设置和删除了Transfer-Encoding标头?
Who set and remove the Transfer-Encoding header?
推荐答案
当您不指定内容长度时,Apache将设置Transfer-Encoding: chunked
.您不应该尝试自己设置该标头. WSGI规范实际上禁止您使用( https://www.python.org/dev/peps/pep-3333/#id34 ),因为它是逐跳标题.
Apache will set Transfer-Encoding: chunked
when you don't specify a content length. You should not attempt to set that header yourself. The WSGI specification actually forbids you (https://www.python.org/dev/peps/pep-3333/#id34) from setting, as it is a hop-by-hop header.
设置内容长度后,HTTP无需使用分块响应编码.
When a content length is set, HTTP doesn't need to use chunked response encoding.
这篇关于谁设置了Transfer-Encoding:块头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!