user3413814
user3413814

Reputation: 125

Who set the Transfer-Encoding: chunked header?

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

Answers (1)

Graham Dumpleton
Graham Dumpleton

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

Related Questions