From: Jim Jagielski Date: Thu, 5 Sep 2002 14:19:19 +0000 (+0000) Subject: When the cache would validate 304 responses from back-end server, it would X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=456a15c6cad5802a538b80c6a636fcce22f8fbf2;p=thirdparty%2Fapache%2Fhttpd.git When the cache would validate 304 responses from back-end server, it would incorrectly set the content-length value to 0 (from the 304 response) instead of keeping the original value. PR: Bugz 10128 Obtained from: Submitted by: Paul Terry and ast@domdv.de Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@96647 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/CHANGES b/src/CHANGES index e6e5c67c2ba..0ae33c413a9 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -1,5 +1,9 @@ Changes with Apache 1.3.27 + *) The cache in mod_proxy was incorrectly updating the Content-Length + value (to 0) from 304 responses when doing validation. Bugz#10128 + [Paul Terry , ast@domdv.de, Jim Jagielski] + *) Added support for Berkeley-DB/4.x to mod_auth_db. [Martin Kraemer] diff --git a/src/modules/proxy/proxy_cache.c b/src/modules/proxy/proxy_cache.c index ff2bb0681f2..111ac5c2e07 100644 --- a/src/modules/proxy/proxy_cache.c +++ b/src/modules/proxy/proxy_cache.c @@ -1524,7 +1524,7 @@ int ap_proxy_cache_update(cache_req *c, table *resp_hdrs, if (clen == NULL) c->len = -1; else - c->len = atoi(clen); + c->len = ap_strtol(clen, NULL, 10); /* we have all the header information we need - write it to the cache file */ c->version++; @@ -1560,6 +1560,18 @@ int ap_proxy_cache_update(cache_req *c, table *resp_hdrs, */ if (c->hdrs) { + /* recall at this point that c->len is already set from resp_hdrs. + If Content-Length was NULL, then c->len is -1, otherwise it's + set to whatever the value was. */ + if (c->len == 0) { + const char *c_clen_str; + off_t c_clen; + if ( (c_clen_str = ap_table_get(c->hdrs, "Content-Length")) && + ( (c_clen = ap_strtol(c_clen_str, NULL, 10)) > 0) ) { + ap_table_set(resp_hdrs, "Content-Length", c_clen_str); + c->len = c_clen; + } + } if (!ap_proxy_table_replace(c->hdrs, resp_hdrs)) { c->xcache = ap_pstrcat(r->pool, "HIT from ", ap_get_server_name(r), " (with revalidation)", NULL); return ap_proxy_cache_conditional(r, c, c->fp);