Transfer-encoding: chunked

215 views
Skip to first unread message

Eric Montgomery

unread,
Aug 9, 2008, 1:38:31 AM8/9/08
to Django users
I'm not sure what is causing this, but I'm pretty sure it's either
django or mod_python.

I have Apache with mod_python running behind nginx which acts as a
reverse proxy. When I set up virtual hosts for a non-django site, I
can get Apache to serve static files with a Content-Length header.
However, from my django app, I get a "Transfer-Encoding: chunked"
header instead. The only difference between the two as far as server
configuration is that I have the '<Location "/">' directive with the
basic django/mod_python settings in the virtual host for the django
site. Otherwise, the settings are the same, so I have a feeling that
django or mod_python is responsible.

Also, and this is probably unrelated, Apache is returning a
"Connection: keep-alive" header even though I have "KeepAlive Off" in
the virtual host configuration.

Mike Blake

unread,
Aug 9, 2008, 8:01:54 AM8/9/08
to Django users

I've got an ubuntu 8.04 apache2 / mod_python / django installation and
I'm not getting the KeepAlive in the response header when I've got it
set to Off in the virtualhost or the global apache configuration.
(I've tried both).

But to answer the chunked issue (as I've had this before): if the
content length is not known, then apache will use chunked encoding. So
it's not a django or mod_python issue.

Eric Montgomery

unread,
Aug 9, 2008, 11:43:31 AM8/9/08
to Django users
So is there anything I can do so that Apache can know the content
length?

Mike Blake

unread,
Aug 9, 2008, 5:45:34 PM8/9/08
to Django users

Usually you just output it as a header. ie:

HTTP/1.x 200 OK

Pragma: no-cache

Expires: Fri, 01 Jan 1990 00:00:00 GMT

Cache-Control: no-cache, must-revalidate

Content-Type: text/html; charset=UTF-8

Content-Encoding: gzip

Content-Length: 8186
# Here it is!
Date: Sun, 10 Aug 2008 00:003:00 GMT


but it obviously requires you to have worked out the size of the
output before you begin the output itself.
Reply all
Reply to author
Forward
0 new messages