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 <estrade-m@ifrance.com>
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@97542
13f79535-47bb-0310-9956-
ffa450edef68
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 <estrade-m@ifrance.com>, Brian Pane]
+
*) mod_cgid: Handle environment variables containing newlines.
PR 14550 [Piotr Czejkowski <apache@czarny.eu.org>, Jeff
Trawick]
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;
+}
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
*/
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);
/* 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;
}