(C) 2001 [ t]ivano Software GmbH http://www.tivano.de/ THIS SOFTWARE IS PROVIDED WITHOUT WARRANTY OF ANY KIND. USE AT YOUR OWN RISK! Send your comments / improvements / criticism to conrad@tivano.de. This patch enables persistent connections for HTTP/1.0 requests as described in RFC 2616 section 19.6.2. WARNING: There are some known problems with older proxy servers. Read the RFC before you apply this patch! diff -rNC3 publicfile-0.52.orig/httpd.c publicfile-0.52/httpd.c *** publicfile-0.52.orig/httpd.c Tue Nov 9 08:23:46 1999 --- publicfile-0.52/httpd.c Tue Nov 6 11:20:52 2001 *************** *** 61,66 **** --- 61,68 ---- struct tai mtimeage; stralloc mtimestr = {0}; + int http10_keep_alive = 0; + void header(char *code,char *message) { if (protocolnum == 1) *************** *** 154,159 **** --- 156,163 ---- out_puts("Content-Length: "); out_put(strnum,fmt_ulong(strnum,length)); /* XXX: could change */ out_puts("\r\n"); + if (http10_keep_alive) + out_puts("Connection: keep-alive\r\n"); } out_puts("\r\n"); } *************** *** 167,175 **** out_put(filebuf,r); } out_flush(); ! _exit(0); } if (flagbody) for (;;) { r = read(fd,filebuf,sizeof filebuf); --- 171,184 ---- out_put(filebuf,r); } out_flush(); ! /* RFC 2616 (HTTP/1.1 spec) section 19.6.2 and RFC 2068 section 19.7.1 ! * specify means to use HTTP/1.0 persistent connections. ! */ ! if (!http10_keep_alive) ! _exit(0); } + if (protocolnum >= 2) { if (flagbody) for (;;) { r = read(fd,filebuf,sizeof filebuf); *************** *** 181,186 **** --- 190,196 ---- out_puts("\r\n"); } + } /* protocolnum >= 2 */ close(fd); } *************** *** 228,233 **** --- 238,244 ---- if (!stralloc_copys(&protocol,"")) _exit(21); if (!stralloc_copys(&ims,"")) _exit(21); protocolnum = 2; + http10_keep_alive = 0; spaces = 0; for (i = 0;i < line.len;++i) *************** *** 282,287 **** --- 293,301 ---- for (;;) { readline(); if (!line.len || ((line.s[0] != ' ') && (line.s[0] != '\t'))) { + if (protocolnum == 1 && + case_startb(field.s,field.len,"connection: keep-alive")) + http10_keep_alive = 1; if (case_startb(field.s,field.len,"content-length:")) barf("501 ","I do not accept messages"); if (case_startb(field.s,field.len,"transfer-encoding:"))