谁设置了Transfer-Encoding:块头? [英] Who set the Transfer-Encoding: chunked header?

查看:220
本文介绍了谁设置了Transfer-Encoding:块头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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:块头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆