You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Alexei Kosut <ak...@nueva.pvt.k12.ca.us> on 1996/02/03 06:44:35 UTC

Patch to implement Keep-Alive

Hi folks...

I've uploaded to /httpd/incoming a patch, keepalive.patch, that implements
persistent connections as per the HTTP/1.1 draft - the same way that
NCSA/1.5, Spyglass Server, Netscape Navigator 2.0 and NCSA Mosaic 2.6/X
do. I figure it's about time... (and it was simple, too...  add a while
loop in http_main.c, stick some support code in http_protocol.c and
httpd.h, and viola. Did I miss something?)

Anyhow, near as I can tell, it works. Whenever someone sends the server a
Connection:  Keep-Alive and the response contains a Content-length header,
or has no body (e.g. a HEAD response or a 302 Not Modified), it sends
along a Connection: Keep-Alive in response, and keeps the connection open.
It does this indefinitely, until either they request a document without
sending Keep-Alive, they request a document that has an unknown length,
they close the connection, or it times out.

That last thing is the one problem. See, my knowledge of handling sockets
and TCP and stuff in C isn't great (you want proof? Go read my mod_proxy),
so I didn't fix this (don't know how), but when someone requests a
document with keep-alive, and then just sits there, it sits there until it
times out. Which is whatever you have Timeout set to (400 secs default in
the config files). While you want to keep it open long enough for
reasonable after-requests to be made (inline images, the user has clicked
on a link quickly after loading the page), you don't want a million
clients just keeping connections open to your server and not doing
anything. So the timeout at that one point (once they get sent a
request-line, it should go back to normal) should probably be about 20-30
seconds. If anyone wants to take the patch and make it so that it happens
that way, please do.

Other than that, it does work wonderfully. At least, it seems to. 
According to the spec, at least. I don't really know if it works. I don't
have a browser I can gaurantee actually uses Keep-Alive (Netscape 2.0
sends it, but for all I know it just closes the connection after it gets
the data anyhow), so I can't test that, but it seems to work. If someone
could move the patch over to for_Apache_1.0.2, I'd like to see it there. 

Oh, and I'm leaving town for the weekend, so after tonight I won't read
any replies until Monday.

Thanks!

--/ Alexei Kosut <ak...@nueva.pvt.k12.ca.us> /--------/ Lefler on IRC
----------------------------/ <http://www.nueva.pvt.k12.ca.us/~akosut/>
The viewpoints expressed above are entirely false, and in no way
represent Alexei Kosut nor any other person or entity. /--------------