httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk-Willem van Gulik <di...@webweaving.org>
Subject Re: Centralizing http-proxy knowledge in cache_util.c (resend with fix)
Date Thu, 17 Apr 2008 11:09:48 GMT
(Resent - previous patch also contained the module changes).

Before I give the other modules a pass over -- does below strawman  
address everyones
concerns w.r. to the API changes ?

To recap:

-	ap_cache_cacheable_hdrs_out gets depricated. And the repliced
	code is to be removed from mod_*_cache.

-	a ap_cache_cacheable_hdrs_in() and ap_cache_cacheable_hdrs_out()
	are added, which each rely on:

-	ap_cache_cacheable_headers - which knows the HTTP rules.

The intention is to make sure that caching modules do no longer have to
understand the section in RFC 2616 deling with hop-by-hop.

Right now _out is just a wrapper for ap_cache_cacheable_headers - but
I expect that we'll have to populate it soon. And to avoid an API  
version
bump I'd thus rather not do it as a #define for now.

Thanks,

Dw.

Index: CHANGES
===================================================================
--- CHANGES	(revision 649044)
+++ CHANGES	(working copy)
@@ -2,6 +2,14 @@
Changes with Apache 2.3.0
[ When backported to 2.2.x, remove entry from this file ]

+  *) cache: remove 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_hdrs_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: modules/cache/mod_cache.h
===================================================================
--- modules/cache/mod_cache.h	(revision 649044)
+++ modules/cache/mod_cache.h	(working copy)
@@ -286,9 +286,27 @@
                                     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,
                                                         server_rec *s);

Index: modules/cache/cache_util.c
===================================================================
--- modules/cache/cache_util.c	(revision 649044)
+++ modules/cache/cache_util.c	(working copy)
@@ -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.
      */
@@ -614,3 +623,44 @@
     }
     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_hdrs(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_hdrs(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: include/ap_mmn.h
===================================================================
--- include/ap_mmn.h	(revision 649044)
+++ include/ap_mmn.h	(working copy)
@@ -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


Mime
View raw message