summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk-Willem van Gulik <dirkx@apache.org>2008-04-17 16:03:13 +0000
committerDirk-Willem van Gulik <dirkx@apache.org>2008-04-17 16:03:13 +0000
commit53d475f654bf7c538682ae429e88d4c8e702ce94 (patch)
tree8c6a1dcab12cc65f8bce5af08e3d131b045fb4e4
parentae2b139ec9a072845f310a14d3ad226308ad7902 (diff)
downloadhttpd-53d475f654bf7c538682ae429e88d4c8e702ce94.tar.gz
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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@649162 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--CHANGES8
-rw-r--r--include/ap_mmn.h4
-rw-r--r--modules/cache/cache_util.c54
-rw-r--r--modules/cache/mod_cache.h22
4 files changed, 83 insertions, 5 deletions
diff --git a/CHANGES b/CHANGES
index ca2b0d226b..68c6a8439f 100644
--- 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>]
diff --git a/include/ap_mmn.h b/include/ap_mmn.h
index 64aff06e27..54fa1c036a 100644
--- a/include/ap_mmn.h
+++ b/include/ap_mmn.h
@@ -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
diff --git a/modules/cache/cache_util.c b/modules/cache/cache_util.c
index de8f385921..2317d97c68 100644
--- a/modules/cache/cache_util.c
+++ b/modules/cache/cache_util.c
@@ -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;
+}
diff --git a/modules/cache/mod_cache.h b/modules/cache/mod_cache.h
index c58713c6c8..cc70558963 100644
--- a/modules/cache/mod_cache.h
+++ b/modules/cache/mod_cache.h
@@ -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,