fielding 97/08/15 10:59:55
Modified: src CHANGES src/core http_protocol.c src/modules/proxy mod_proxy.h proxy_cache.c proxy_ftp.c proxy_http.c Log: Force proxy to always respond as HTTP/1.0, which it was failing to do for errors and cached responses. Revision Changes Path 1.396 +6 -1 apachen/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apachen/src/CHANGES,v retrieving revision 1.395 retrieving revision 1.396 diff -u -r1.395 -r1.396 --- CHANGES 1997/08/11 21:17:24 1.395 +++ CHANGES 1997/08/15 17:59:47 1.396 @@ -417,7 +417,12 @@ *) PORT: Added Windows NT support [Ben Laurie and Ambarish Malpani <[EMAIL PROTECTED]>] -Changes with Apache 1.2.2 +Changes with Apache 1.2.3 + + *) Force proxy to always respond as HTTP/1.0, which it was failing to + do for errors and cached responses. [Roy Fielding] + +Changes with Apache 1.2.2 [not released] *) Fixed another long-standing bug in sub_req_lookup_file where it would happily skip past access checks on subdirectories looked up with relative 1.152 +9 -2 apachen/src/core/http_protocol.c Index: http_protocol.c =================================================================== RCS file: /export/home/cvs/apachen/src/core/http_protocol.c,v retrieving revision 1.151 retrieving revision 1.152 diff -u -r1.151 -r1.152 --- http_protocol.c 1997/08/05 08:24:33 1.151 +++ http_protocol.c 1997/08/15 17:59:50 1.152 @@ -1090,9 +1090,16 @@ if (!r->status_line) r->status_line = status_lines[index_of_response(r->status)]; - if (r->proto_num == 1000 - && table_get(r->subprocess_env,"force-response-1.0")) + /* mod_proxy is only HTTP/1.0, so avoid sending HTTP/1.1 error response; + * kluge around broken browsers when indicated by force-response-1.0 + */ + if (r->proxyreq + || (r->proto_num == 1000 + && table_get(r->subprocess_env,"force-response-1.0"))) { + protocol = "HTTP/1.0"; + r->connection->keepalive = -1; + } else protocol = SERVER_PROTOCOL; 1.17 +1 -1 apachen/src/modules/proxy/mod_proxy.h Index: mod_proxy.h =================================================================== RCS file: /export/home/cvs/apachen/src/modules/proxy/mod_proxy.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- mod_proxy.h 1997/08/01 04:58:01 1.16 +++ mod_proxy.h 1997/08/15 17:59:51 1.17 @@ -235,7 +235,7 @@ int proxy_cache_check(request_rec *r, char *url, struct cache_conf *conf, struct cache_req **cr); int proxy_cache_update(struct cache_req *c, array_header *resp_hdrs, - const char *protocol, int nocache); + const int is_HTTP1, int nocache); void proxy_garbage_coll(request_rec *r); /* proxy_connect.c */ 1.22 +2 -3 apachen/src/modules/proxy/proxy_cache.c Index: proxy_cache.c =================================================================== RCS file: /export/home/cvs/apachen/src/modules/proxy/proxy_cache.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- proxy_cache.c 1997/07/21 05:54:04 1.21 +++ proxy_cache.c 1997/08/15 17:59:52 1.22 @@ -621,7 +621,7 @@ */ int proxy_cache_update(struct cache_req *c, array_header *resp_hdrs, - const char *protocol, int nocache) + const int is_HTTP1, int nocache) { request_rec *r=c->req; char *p; @@ -672,8 +672,7 @@ if ((r->status != 200 && r->status != 301 && r->status != 304) || (expire != NULL && expc == BAD_DATE) || (r->status == 304 && c->fp == NULL) || - (r->status == 200 && lmods == NULL && - strncmp(protocol, "HTTP/1.", 7) == 0) || + (r->status == 200 && lmods == NULL && is_HTTP1) || r->header_only || table_get(r->headers_in, "Authorization") != NULL || nocache) 1.32 +1 -1 apachen/src/modules/proxy/proxy_ftp.c Index: proxy_ftp.c =================================================================== RCS file: /export/home/cvs/apachen/src/modules/proxy/proxy_ftp.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- proxy_ftp.c 1997/08/13 08:37:21 1.31 +++ proxy_ftp.c 1997/08/15 17:59:52 1.32 @@ -936,7 +936,7 @@ nocache = 1; } - i = proxy_cache_update(c, resp_hdrs, "FTP", nocache); + i = proxy_cache_update(c, resp_hdrs, 0, nocache); if (i != DECLINED) { 1.26 +12 -14 apachen/src/modules/proxy/proxy_http.c Index: proxy_http.c =================================================================== RCS file: /export/home/cvs/apachen/src/modules/proxy/proxy_http.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- proxy_http.c 1997/08/02 00:58:34 1.25 +++ proxy_http.c 1997/08/15 17:59:52 1.26 @@ -143,7 +143,7 @@ { char *p; const char *err, *desthost; - int i, j, sock, len; + int i, j, sock, len, backasswards; array_header *reqhdrs_arr, *resp_hdrs; table_entry *reqhdrs; struct sockaddr_in server; @@ -151,7 +151,7 @@ struct hostent server_hp; BUFF *f, *cache; struct hdr_entry *hdr; - char buffer[HUGE_STRING_LEN], inprotocol[9], outprotocol[9]; + char buffer[HUGE_STRING_LEN]; pool *pool=r->pool; const long int zero=0L; int destport = 0; @@ -308,7 +308,7 @@ return proxyerror(r, "Error reading from remote server"); } -/* Is it an HTTP/1 response? */ +/* Is it an HTTP/1 response? This is buggy if we ever see an HTTP/1.10 */ if (checkmask(buffer, "HTTP/#.# ###*")) { /* If not an HTTP/1 messsage or if the status line was > 8192 bytes */ @@ -318,12 +318,9 @@ kill_timeout(r); return BAD_GATEWAY; } + backasswards = 0; buffer[--len] = '\0'; - memcpy(inprotocol, buffer, 8); - inprotocol[8] = '\0'; -/* we use the same protocol on output as on input */ - strcpy(outprotocol, inprotocol); buffer[12] = '\0'; r->status = atoi(&buffer[9]); buffer[12] = ' '; @@ -334,11 +331,13 @@ /* Also, take care with headers with multiple occurences. */ resp_hdrs = proxy_read_headers(pool, buffer, HUGE_STRING_LEN, f); - } else + + clear_connection((table *)resp_hdrs); /* Strip Connection hdrs */ + } + else { /* an http/0.9 response */ - strcpy(inprotocol, "HTTP/0.9"); - strcpy(outprotocol, "HTTP/1.0"); + backasswards = 1; r->status = 200; r->status_line = "200 OK"; @@ -372,7 +371,7 @@ nocache = 1; } - i = proxy_cache_update(c, resp_hdrs, inprotocol, nocache); + i = proxy_cache_update(c, resp_hdrs, !backasswards, nocache); if (i != DECLINED) { bclose(f); @@ -387,8 +386,7 @@ if (!r->assbackwards) rvputs(r, "HTTP/1.0 ", r->status_line, "\015\012", NULL); if (cache != NULL) - if (bvputs(cache, outprotocol, " ", r->status_line, "\015\012", NULL) - == -1) + if (bvputs(cache, "HTTP/1.0 ", r->status_line, "\015\012", NULL) == -1) cache = proxy_cache_error(c); /* send headers */ @@ -411,7 +409,7 @@ bsetopt(r->connection->client, BO_BYTECT, &zero); r->sent_bodyct = 1; /* Is it an HTTP/0.9 respose? If so, send the extra data */ - if (strcmp(inprotocol, "HTTP/0.9") == 0) + if (backasswards) { bwrite(r->connection->client, buffer, len); if (cache != NULL)