httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r892260 - in /httpd/httpd/branches/2.2.x: CHANGES STATUS modules/cache/mod_disk_cache.c modules/cache/mod_mem_cache.c
Date Fri, 18 Dec 2009 14:13:05 GMT
Author: jim
Date: Fri Dec 18 14:13:05 2009
New Revision: 892260

URL: http://svn.apache.org/viewvc?rev=892260&view=rev
Log:
  * mod_disk_cache, mod_mem_cache: don't cache incomplete responses,
      per RFC 2616, 13.8.
          PR 15866
              Trunk Patch: http://svn.apache.org/viewvc?rev=818492&view=rev
                               http://svn.apache.org/viewvc?rev=821763&view=rev
                                   2.2.x Patch: http://people.apache.org/~poirier/PR15866-22x.patch
                                       +1: poirier, rpluem, rjung, jim



Modified:
    httpd/httpd/branches/2.2.x/CHANGES
    httpd/httpd/branches/2.2.x/STATUS
    httpd/httpd/branches/2.2.x/modules/cache/mod_disk_cache.c
    httpd/httpd/branches/2.2.x/modules/cache/mod_mem_cache.c

Modified: httpd/httpd/branches/2.2.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/CHANGES?rev=892260&r1=892259&r2=892260&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Fri Dec 18 14:13:05 2009
@@ -27,6 +27,9 @@
      for the default values of 1024 for LdapCacheEntries/LdapOpCacheEntries.
      PR 46749. [Stefan Fritsch]
 
+  *) mod_disk_cache, mod_mem_cache: don't cache incomplete responses,
+     per RFC 2616, 13.8.  PR15866.  [Dan Poirier]
+
   *) mod_rewrite: Make sure that a hostname:port isn't fully qualified if
      the request is a CONNECT request. PR 47928
      [Bill Zajac <billz consultla.com>]

Modified: httpd/httpd/branches/2.2.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/STATUS?rev=892260&r1=892259&r2=892260&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/STATUS (original)
+++ httpd/httpd/branches/2.2.x/STATUS Fri Dec 18 14:13:05 2009
@@ -87,14 +87,6 @@
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  * mod_disk_cache, mod_mem_cache: don't cache incomplete responses,
-    per RFC 2616, 13.8.
-    PR 15866
-    Trunk Patch: http://svn.apache.org/viewvc?rev=818492&view=rev
-                 http://svn.apache.org/viewvc?rev=821763&view=rev
-    2.2.x Patch: http://people.apache.org/~poirier/PR15866-22x.patch
-    +1: poirier, rpluem, rjung, jim
-
   * mod_filter: dispatch correctly where dispatch string doesn't exist
     PR 48054
     Trunk patch: n/a (trunk upgraded to use ap_expr for condition testing)

Modified: httpd/httpd/branches/2.2.x/modules/cache/mod_disk_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/cache/mod_disk_cache.c?rev=892260&r1=892259&r2=892260&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/cache/mod_disk_cache.c (original)
+++ httpd/httpd/branches/2.2.x/modules/cache/mod_disk_cache.c Fri Dec 18 14:13:05 2009
@@ -1041,6 +1041,8 @@
      * sanity checks.
      */
     if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb))) {
+        const char *cl_header = apr_table_get(r->headers_out, "Content-Length");
+
         if (r->connection->aborted || r->no_cache) {
             ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
                          "disk_cache: Discarding body for URL %s "
@@ -1059,6 +1061,17 @@
             file_cache_errorcleanup(dobj, r);
             return APR_EGENERAL;
         }
+        if (cl_header) {
+            apr_size_t cl = apr_atoi64(cl_header);
+            if ((errno == 0) && (dobj->file_size != cl)) {
+                ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                             "disk_cache: URL %s didn't receive complete response, not caching",
+                             h->cache_obj->key);
+                /* Remove the intermediate cache file and return non-APR_SUCCESS */
+                file_cache_errorcleanup(dobj, r);
+                return APR_EGENERAL;
+            }
+        }
 
         /* All checks were fine. Move tempfile to final destination */
         /* Link to the perm file, and close the descriptor */

Modified: httpd/httpd/branches/2.2.x/modules/cache/mod_mem_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/cache/mod_mem_cache.c?rev=892260&r1=892259&r2=892260&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/cache/mod_mem_cache.c (original)
+++ httpd/httpd/branches/2.2.x/modules/cache/mod_mem_cache.c Fri Dec 18 14:13:05 2009
@@ -745,6 +745,16 @@
         apr_size_t len;
 
         if (APR_BUCKET_IS_EOS(e)) {
+            const char *cl_header = apr_table_get(r->headers_out, "Content-Length");
+            if (cl_header) {
+                apr_size_t cl = apr_atoi64(cl_header);
+                if ((errno == 0) && (obj->count != cl)) {
+                    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                                 "mem_cache: URL %s didn't receive complete response, not
caching",
+                                 h->cache_obj->key);
+                    return APR_EGENERAL;
+                }
+            }
             if (mobj->m_len > obj->count) {
                 /* Caching a streamed response. Reallocate a buffer of the
                  * correct size and copy the streamed response into that



Mime
View raw message