Reputation: 125
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?
Upvotes: 0
Views: 2442
Reputation: 58523
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.
Upvotes: 2