]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
When the cache would validate 304 responses from back-end server, it would
authorJim Jagielski <jim@apache.org>
Thu, 5 Sep 2002 14:19:19 +0000 (14:19 +0000)
committerJim Jagielski <jim@apache.org>
Thu, 5 Sep 2002 14:19:19 +0000 (14:19 +0000)
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 <paul.terry@gmx.net> 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

src/CHANGES
src/modules/proxy/proxy_cache.c

index e6e5c67c2baae5e29841e209fced04f19e79a2b2..0ae33c413a99a23b4559eadd637bea314f82a210 100644 (file)
@@ -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 <paul.terry@gmx.net>, ast@domdv.de, Jim Jagielski]
+
   *) Added support for Berkeley-DB/4.x to mod_auth_db.
      [Martin Kraemer]
 
index ff2bb0681f2aeccc6a4518a4b6cb043945f9d541..111ac5c2e07b042d18062640a626e96cf1e28a2f 100644 (file)
@@ -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);