akosut 96/09/02 17:31:29
Modified: src http_protocol.c httpd.h
Log:
Upgrade protocol version to 1.1. Clean up persistent connection support
a bit.
Reviewed by: Rob Hartill, Jim Jagielski, Chuck Murcko, Roy T. Fielding
Revision Changes Path
1.45 +14 -24 apache/src/http_protocol.c
Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_protocol.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -C3 -r1.44 -r1.45
*** http_protocol.c 1996/08/24 16:04:54 1.44
--- http_protocol.c 1996/09/03 00:31:26 1.45
***************
*** 50,56 ****
*
*/
! /* $Id: http_protocol.c,v 1.44 1996/08/24 16:04:54 ben Exp $ */
/*
* http_protocol.c --- routines which directly communicate with the
--- 50,56 ----
*
*/
! /* $Id: http_protocol.c,v 1.45 1996/09/03 00:31:26 akosut Exp $ */
/*
* http_protocol.c --- routines which directly communicate with the
***************
*** 284,316 ****
{
char *conn = table_get (r->headers_in, "Connection");
char *length = table_get (r->headers_out, "Content-length");
if ((r->server->keep_alive > r->connection->keepalives) &&
(r->server->keep_alive_timeout > 0) &&
(r->header_only || length ||
((r->proto_num >= 1001) && (r->byterange > 1 || (r->chunked = 1)))) &&
(!find_token(r->pool, conn, "close")) &&
! #ifdef FORHTTP11
! ((proto_num >= 1001) || find_token(r->pool, conn, "keep-alive"))) {
! #else
! (find_token(r->pool, conn, "keep-alive"))) {
! #endif
char header[26];
int left = r->server->keep_alive - r->connection->keepalives;
r->connection->keepalive = 1;
r->connection->keepalives++;
! #ifdef FORHTTP11
! if (r->proto_num < 1001) {
! #endif
sprintf(header, "timeout=%d, max=%d",
r->server->keep_alive_timeout, left);
! table_merge (r->headers_out, "Connection", "Keep-Alive");
! table_set (r->headers_out, "Keep-Alive", pstrdup(r->pool, header));
! #ifdef FORHTTP11
}
- #endif
return 1;
}
--- 284,311 ----
{
char *conn = table_get (r->headers_in, "Connection");
char *length = table_get (r->headers_out, "Content-length");
+ int ka_sent;
if ((r->server->keep_alive > r->connection->keepalives) &&
(r->server->keep_alive_timeout > 0) &&
(r->header_only || length ||
((r->proto_num >= 1001) && (r->byterange > 1 || (r->chunked = 1)))) &&
(!find_token(r->pool, conn, "close")) &&
! ((ka_sent = find_token(r->pool, conn, "keep-alive")) ||
! r->proto_num >= 1001)) {
char header[26];
int left = r->server->keep_alive - r->connection->keepalives;
r->connection->keepalive = 1;
r->connection->keepalives++;
! /* If they sent a Keep-Alive token, send one back */
! if (ka_sent) {
sprintf(header, "timeout=%d, max=%d",
r->server->keep_alive_timeout, left);
! rputs("Connection: Keep-Alive\015\012", r);
! rvputs(r, "Keep-Alive: ", header, "\015\012", NULL);
}
return 1;
}
***************
*** 320,326 ****
* as HTTP/1.0, but pass our request along with our HTTP/1.1 tag
* to a HTTP/1.1 client. Better safe than sorry.
*/
! table_merge (r->headers_out, "Connection", "close");
return 0;
}
--- 315,321 ----
* as HTTP/1.0, but pass our request along with our HTTP/1.1 tag
* to a HTTP/1.1 client. Better safe than sorry.
*/
! rputs("Connection: close\015\012", r);
return 0;
}
***************
*** 1274,1293 ****
if (etag) bvputs(c->client, "ETag: ", etag, "\015\012", NULL);
if (cloc) bvputs(c->client, "Content-Location: ", cloc,
"\015\012", NULL);
! if (set_keepalive(r)) {
! #ifdef FORHTTP11
! if (r->proto_num < 1001)
! #endif
! bputs("Connection: Keep-Alive\015\012", c->client);
! }
! else bputs("Connection: close\015\012", c->client);
bputs("\015\012", c->client);
return;
}
! /* We don't want persistent connections here, for several reasons.
! * Most importantly, if there's been an error, we don't want
! * it screwing up the next request.
*/
bputs("Connection: close\015\012", c->client);
--- 1269,1283 ----
if (etag) bvputs(c->client, "ETag: ", etag, "\015\012", NULL);
if (cloc) bvputs(c->client, "Content-Location: ", cloc,
"\015\012", NULL);
! set_keepalive(r);
bputs("\015\012", c->client);
return;
}
! /* Someday, we'd like to have persistent connections here.
! * They're especially useful for redirects, multiple choices
! * and auth requests. But we need to rewrite the rest of thi
! * section, so for now, we don't use it.
*/
bputs("Connection: close\015\012", c->client);
1.49 +2 -2 apache/src/httpd.h
Index: httpd.h
===================================================================
RCS file: /export/home/cvs/apache/src/httpd.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -C3 -r1.48 -r1.49
*** httpd.h 1996/08/24 16:33:29 1.48
--- httpd.h 1996/09/03 00:31:27 1.49
***************
*** 50,56 ****
*
*/
! /* $Id: httpd.h,v 1.48 1996/08/24 16:33:29 ben Exp $ */
/*
* httpd.h: header for simple (ha! not anymore) http daemon
--- 50,56 ----
*
*/
! /* $Id: httpd.h,v 1.49 1996/09/03 00:31:27 akosut Exp $ */
/*
* httpd.h: header for simple (ha! not anymore) http daemon
***************
*** 245,251 ****
#define SERVER_VERSION "Apache/1.2-dev" /* SEE COMMENTS ABOVE */
! #define SERVER_PROTOCOL "HTTP/1.0"
#define SERVER_SUPPORT "http://www.apache.org/"
#define DECLINED -1 /* Module declines to handle */
--- 245,251 ----
#define SERVER_VERSION "Apache/1.2-dev" /* SEE COMMENTS ABOVE */
! #define SERVER_PROTOCOL "HTTP/1.1"
#define SERVER_SUPPORT "http://www.apache.org/"
#define DECLINED -1 /* Module declines to handle */