Who set the Transfer-Encoding: chunked header?

淺唱寂寞╮ 提交于 2019-12-11 15:55:12

问题


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.

Who set and remove the Transfer-Encoding header?


回答1:


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.

When a content length is set, HTTP doesn't need to use chunked response encoding.



来源:https://stackoverflow.com/questions/49621559/who-set-the-transfer-encoding-chunked-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!