]> granicus.if.org Git - apache/commitdiff
Currently each of the caching module includes logic to implement
authorDirk-Willem van Gulik <dirkx@apache.org>
Thu, 17 Apr 2008 16:03:13 +0000 (16:03 +0000)
committerDirk-Willem van Gulik <dirkx@apache.org>
Thu, 17 Apr 2008 16:03:13 +0000 (16:03 +0000)
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.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@649162 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
include/ap_mmn.h
modules/cache/cache_util.c
modules/cache/mod_cache.h

diff --git a/CHANGES b/CHANGES
index ca2b0d226b011fafc6742e84bea23b98a9e5644e..68c6a8439f21597b78a51d0238afdcdce00a145b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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>]
 
index 64aff06e27bbed923c9486c5f7782fcfeed146c9..54fa1c036a45532cffd2f57d9c0ecec1adadb80e 100644 (file)
  * 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" */
 #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
index de8f385921b41212d6f54b91470065ded0a714cb..2317d97c687c1daa90fce03963b07fd74d4ff617 100644 (file)
@@ -577,10 +577,10 @@ CACHE_DECLARE(char *)ap_cache_generate_name(apr_pool_t *p, int dirlevels,
     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 @@ CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool,
     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 @@ CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool,
 
     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.
      */
@@ -614,3 +623,44 @@ CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool,
     }
     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;
+}
index c58713c6c8b68d6bf4b2b1f7cc71bfd3a95c6abd..cc70558963d79422dfaf47dc0cda1c87e147f0e6 100644 (file)
@@ -286,8 +286,26 @@ CACHE_DECLARE(int) ap_cache_liststr(apr_pool_t *p, const char *list,
                                     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,