You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by di...@apache.org on 2008/04/17 18:03:15 UTC

svn commit: r649162 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h modules/cache/cache_util.c modules/cache/mod_cache.h

Author: dirkx
Date: Thu Apr 17 09:03:13 2008
New Revision: 649162

URL: http://svn.apache.org/viewvc?rev=649162&view=rev
Log:
Currently each of the caching module includes logic to implement
the hop-by-hop rules of rfc 2616 along with the entity response
rules. To make sure that they stay in sync; and to make it easier
to add (http) caching modules - this change moves them all into
one place (cache_util) and exposes a in-bound and out-bound
version to operate on the headers.

In short: we retire ap_cache_cacheable_hdrs_out() which was used
for both in- and out-put headers; and replace it by a single
ap_cache_cacheable_headers() which understands the hop-by-hop
rules. And then wrap this into an in- and out-put specific 
ap_cache_cacheable_headers_in()/out() which we can teach things
about entity responses and so on.. The latter which will also 
merge error and ensure content-type. 

This API change bumps up the minor MM by one.    


Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/modules/cache/cache_util.c
    httpd/httpd/trunk/modules/cache/mod_cache.h

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=649162&r1=649161&r2=649162&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Thu Apr 17 09:03:13 2008
@@ -2,6 +2,14 @@
 Changes with Apache 2.3.0
 [ When backported to 2.2.x, remove entry from this file ]
 
+  *) cache: retire ap_cache_cacheable_hdrs_out() which was used
+     for both in- and out-put headers; and replace it by a single
+     ap_cache_cacheable_headers() wrapped in a in- and out-put
+     specific ap_cache_cacheable_headers_in()/out(). The latter
+     which will also merge error and ensure content-type. To keep
+     cache modules consistent with ease. This API change bumps
+     up the minor MM by one [Dirk-Willem van Gulik].
+
   *) mod_rewrite: Allow Cookie option to set secure and HttpOnly flags.
      PR 44799 [Christian Wenz <christian wenz.org>]
 

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=649162&r1=649161&r2=649162&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Thu Apr 17 09:03:13 2008
@@ -156,6 +156,8 @@
  * 20080403.1 (2.3.0-dev)  Add authn/z hook and provider registration wrappers.
  * 20080403.2 (2.3.0-dev)  Add ap_escape_path_segment_buffer() and ap_unescape_all().
  * 20080407.0 (2.3.0-dev)  Remove ap_graceful_stop_signalled.
+ * 20080407.1              Deprecate ap_cache_cacheable_hdrs_out and add two
+ *                         generalized ap_cache_cacheable_headers_(in|out).
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -163,7 +165,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20080407
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 0                     /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/trunk/modules/cache/cache_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_util.c?rev=649162&r1=649161&r2=649162&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_util.c (original)
+++ httpd/httpd/trunk/modules/cache/cache_util.c Thu Apr 17 09:03:13 2008
@@ -577,10 +577,10 @@
     return apr_pstrdup(p, hashfile);
 }
 
-/* Create a new table consisting of those elements from an input
+/* Create a new table consisting of those elements from an 
  * headers table that are allowed to be stored in a cache.
  */
-CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool,
+CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_headers(apr_pool_t *pool,
                                                         apr_table_t *t,
                                                         server_rec *s)
 {
@@ -588,12 +588,20 @@
     char **header;
     int i;
 
+    /* Short circuit the common case that there are not
+     * (yet) any headers populated.
+     */
+    if (t == NULL) {
+	return apr_table_make(pool, 10);
+    };
+
     /* Make a copy of the headers, and remove from
      * the copy any hop-by-hop headers, as defined in Section
      * 13.5.1 of RFC 2616
      */
     apr_table_t *headers_out;
     headers_out = apr_table_copy(pool, t);
+
     apr_table_unset(headers_out, "Connection");
     apr_table_unset(headers_out, "Keep-Alive");
     apr_table_unset(headers_out, "Proxy-Authenticate");
@@ -605,6 +613,7 @@
 
     conf = (cache_server_conf *)ap_get_module_config(s->module_config,
                                                      &cache_module);
+
     /* Remove the user defined headers set with CacheIgnoreHeaders.
      * This may break RFC 2616 compliance on behalf of the administrator.
      */
@@ -613,4 +622,45 @@
         apr_table_unset(headers_out, header[i]);
     }
     return headers_out;
+}
+
+/* Legacy call - functionally equivalent to ap_cache_cacheable_headers.
+ * @deprecated @see ap_cache_cacheable_headers
+ */
+CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *p,
+                                                        apr_table_t *t,
+                                                        server_rec *s)
+{
+    return ap_cache_cacheable_headers(p,t,s);
+}
+
+/* Create a new table consisting of those elements from an input
+ * headers table that are allowed to be stored in a cache.
+ */
+CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_headers_in(request_rec * r)
+{
+	return ap_cache_cacheable_headers(r->pool, r->headers_in, r->server);
+}
+
+/* Create a new table consisting of those elements from an output
+ * headers table that are allowed to be stored in a cache; 
+ * ensure there is a content type and capture any errors.
+ */
+CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_headers_out(request_rec * r)
+{
+	apr_table_t *headers_out;
+
+	headers_out = ap_cache_cacheable_headers(r->pool, r->headers_out,
+                                                  r->server);
+
+        if (!apr_table_get(headers_out, "Content-Type")
+            && r->content_type) {
+            apr_table_setn(headers_out, "Content-Type",
+                           ap_make_content_type(r, r->content_type));
+        }
+
+        headers_out = apr_table_overlay(r->pool, headers_out,
+                                        r->err_headers_out);
+
+	return headers_out;
 }

Modified: httpd/httpd/trunk/modules/cache/mod_cache.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache.h?rev=649162&r1=649161&r2=649162&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.h (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.h Thu Apr 17 09:03:13 2008
@@ -286,8 +286,26 @@
                                     const char *key, char **val);
 CACHE_DECLARE(const char *)ap_cache_tokstr(apr_pool_t *p, const char *list, const char **str);
 
-/* Create a new table consisting of those elements from a request_rec's
- * headers_out that are allowed to be stored in a cache
+/* Create a new table consisting of those elements from an 
+ * headers table that are allowed to be stored in a cache.
+ */
+CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_headers(apr_pool_t *pool,
+                                                        apr_table_t *t,
+                                                        server_rec *s);
+
+/* Create a new table consisting of those elements from an input
+ * headers table that are allowed to be stored in a cache.
+ */
+CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_headers_in(request_rec * r);
+
+/* Create a new table consisting of those elements from an output
+ * headers table that are allowed to be stored in a cache;
+ * ensure there is a content type and capture any errors.
+ */
+CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_headers_out(request_rec * r);
+
+/* Legacy call - functionally equivalent to ap_cache_cacheable_headers.
+ * @deprecated @see ap_cache_cacheable_headers
  */
 CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool,
                                                         apr_table_t *t,