[mod_python] HTTP-Keep alive bug?

Sébastien Arnaud arnaudsj at mac.com
Mon Aug 9 00:30:16 EDT 2004

Thanks Jonathan for your response.

I have done a little bit more investigation and I think that I managed 
a work around:

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"! Since it is the only way browsers can keep 
connections alive (to know how much bytes they need to expect back from 
the server), 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)

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.

If you set it by hand in your python code like this though:
	ResultHTML = "Your output HTML to the client"

It works, and you can then start to enjoy the performance boost of 
"keep-alive" connections.



On Aug 6, 2004, at 2:18 AM, Jonathan Hseu wrote:

> On Thu, Aug 05, 2004 at 10:54:51PM -0500, S?bastien Arnaud wrote:
>> Hi,
>> I wonder if anybody else had been getting the same problem that I
>> noticed with http keep alive request being not answered properly by
>> mod_python. If you take the very simple mptest example, and use ab to
>> benchmark/stress this trivial example, you may notice that even though
>> you are requesting to use http-keep alive (-k option in ab), the
>> resulting page (http://yourserver/test/mptest.py) is forcing the
>> connection to close (inspect the HTTP headers and see Connection:
>> Close).
> Well, I don't know if this is related, but I do experience an issue 
> with
> keep-alive and mod_python (although, I just assumed it was firefox's
> problem, even though I don't get that bug with anything but firefox).
> Basically, on some keep-alive requests, firefox gives me the HTTP
> headers and other stuff and renders that as text instead of the actual
> page.  Most likely, this is related to your keep-alive bug, since this
> only happens _after_ the first request in a keep-alive request.
> Jonathan Hseu
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 155 bytes
Desc: This is a digitally signed message part
Url : http://modpython.org/pipermail/mod_python/attachments/20040808/b2018e69/PGP.bin

More information about the Mod_python mailing list