[mod_python] HTTP-Keep alive bug?

Gregory (Grisha) Trubetskoy grisha at modpython.org
Mon Aug 9 11:12:50 EDT 2004



On Sun, 8 Aug 2004, [ISO-8859-1] S?bastien Arnaud wrote:

> First, I was wrong when I said mod_python was forcing the HTTP Header 
> "Connection: Close", it is in fact responding to a client request http 
> keep-alive, but it is missing an important part: the HTTP header 
> "Content-Length: xxx"!

If this is HTTP 1.1, then absense of content-length indicates that the 
browser wants chunked-encoding, which means that the output is a number 
indicating size, followed by a chunk of data. With HTTP 1.1 content-length 
is obsolete. There is a pretty good description of it here:

http://www.apacheweek.com/features/http11

> Since it is the only way browsers can keep connections alive (to know 
> how much bytes they need to expect back from the server),

...not with HTTP 1.1

> without it, most browsers will NOT keep the connection alive (maybe your 
> version of Firefox is sensitive to this missing header and tries to wait 
> for more content to come back from the server)

No, this doesn't make a lot of sense. :-) The browser isn't keeping it 
alive because it is seeing a Connection: close, most likely.

> For the record I got mistaken in my early tests because I used Lynx to get 
> the HTTP headers back, and found out that Lynx did not send a valid HTTP 1.1 
> request with keep-alive (duh!), therefore it was ok to receive a "Connection: 
> Close" back then.
>
> Anyway, I think it would be nice to have an explanation why mod_python is not 
> setting by default the Content-Length HTTP header when it is already setting 
> the "Connection: Keep-alive" HTTP header in response to a keep-alive request 
> from the client.

Mod_python does not set the connection header anywhere in the code, but 
other code in Apache probably does. In my experience it is very smart 
about it, so there is more than likely a good reason for it. Something is 
telling Apache to send a "close"... It could the configuration, some 
module in Apache, and it could be something that the browser has caused 
(without seeing the actual headers its hard to tell).

Grisha


More information about the Mod_python mailing list