You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by br...@apache.org on 2002/11/17 02:33:25 UTC
cvs commit: httpd-2.0/modules/experimental mod_cache.h cache_util.c mod_mem_cache.c mod_disk_cache.c
brianp 2002/11/16 17:33:25
Modified: . CHANGES
modules/experimental mod_cache.h cache_util.c
mod_mem_cache.c mod_disk_cache.c
Log:
When storing the response headers in mod_cache, omit Transfer-Encoding
and any other hop-by-hop headers that shouldn't be applied when the
response is later delivered from cache:
http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=103727389213072
Diagnosed by: Estrade Matthieu <es...@ifrance.com>
Revision Changes Path
1.985 +4 -0 httpd-2.0/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/httpd-2.0/CHANGES,v
retrieving revision 1.984
retrieving revision 1.985
diff -u -r1.984 -r1.985
--- CHANGES 15 Nov 2002 02:49:27 -0000 1.984
+++ CHANGES 17 Nov 2002 01:33:24 -0000 1.985
@@ -1,5 +1,9 @@
Changes with Apache 2.0.44
+ *) mod_cache: Don't cache response header fields designated
+ as hop-by-hop headers in HTTP/1.1 (RFC 2616 Section 13.5.1).
+ [Estrade Matthieu <es...@ifrance.com>, Brian Pane]
+
*) mod_cgid: Handle environment variables containing newlines.
PR 14550 [Piotr Czejkowski <ap...@czarny.eu.org>, Jeff
Trawick]
1.36 +5 -0 httpd-2.0/modules/experimental/mod_cache.h
Index: mod_cache.h
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_cache.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- mod_cache.h 30 Oct 2002 14:01:35 -0000 1.35
+++ mod_cache.h 17 Nov 2002 01:33:25 -0000 1.36
@@ -279,6 +279,11 @@
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
+ */
+CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(request_rec *r);
+
/**
* cache_storage.c
*/
1.23 +22 -0 httpd-2.0/modules/experimental/cache_util.c
Index: cache_util.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/cache_util.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- cache_util.c 7 Nov 2002 23:11:09 -0000 1.22
+++ cache_util.c 17 Nov 2002 01:33:25 -0000 1.23
@@ -469,3 +469,25 @@
cache_hash(name, hashfile, dirlevels, dirlength);
return apr_pstrdup(p, hashfile);
}
+
+/* Create a new table consisting of those elements from a request_rec's
+ * headers_out that are allowed to be stored in a cache.
+ */
+CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(request_rec *r)
+{
+ /* Make a copy of the response 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(r->pool, r->headers_out);
+ apr_table_unset(headers_out, "Connection");
+ apr_table_unset(headers_out, "Keep-Alive");
+ apr_table_unset(headers_out, "Proxy-Authenticate");
+ apr_table_unset(headers_out, "Proxy-Authorization");
+ apr_table_unset(headers_out, "TE");
+ apr_table_unset(headers_out, "Trailers");
+ apr_table_unset(headers_out, "Transfer-Encoding");
+ apr_table_unset(headers_out, "Upgrade");
+ return headers_out;
+}
1.88 +1 -1 httpd-2.0/modules/experimental/mod_mem_cache.c
Index: mod_mem_cache.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_mem_cache.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- mod_mem_cache.c 19 Oct 2002 18:24:40 -0000 1.87
+++ mod_mem_cache.c 17 Nov 2002 01:33:25 -0000 1.88
@@ -840,7 +840,7 @@
/* Precompute how much storage we need to hold the headers */
rc = serialize_table(&mobj->header_out,
&mobj->num_header_out,
- r->headers_out);
+ ap_cache_cacheable_hdrs_out(r));
if (rc != APR_SUCCESS) {
return rc;
}
1.45 +3 -2 httpd-2.0/modules/experimental/mod_disk_cache.c
Index: mod_disk_cache.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_disk_cache.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- mod_disk_cache.c 8 Nov 2002 22:42:19 -0000 1.44
+++ mod_disk_cache.c 17 Nov 2002 01:33:25 -0000 1.45
@@ -603,8 +603,9 @@
if (r->headers_out) {
int i;
- apr_table_entry_t *elts = (apr_table_entry_t *) apr_table_elts(r->headers_out)->elts;
- for (i = 0; i < apr_table_elts(r->headers_out)->nelts; ++i) {
+ apr_table_t* headers_out = ap_cache_cacheable_hdrs_out(r);
+ apr_table_entry_t *elts = (apr_table_entry_t *) apr_table_elts(headers_out)->elts;
+ for (i = 0; i < apr_table_elts(headers_out)->nelts; ++i) {
if (elts[i].key != NULL) {
buf = apr_pstrcat(r->pool, elts[i].key, ": ", elts[i].val, CRLF, NULL);
amt = strlen(buf);