diff options
author | Yann Ylavic <ylavic@apache.org> | 2014-05-14 19:11:49 +0200 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2014-05-14 19:11:49 +0200 |
commit | baf4f92af0f97d8bc72460446d2384d849ae0cf3 (patch) | |
tree | 296389468b29bada5c438d9d7e1697c01aff1705 /modules/cache | |
parent | mod_proxy_wstunnel: Fix the use of SSL connections with the "wss:" scheme. (diff) | |
download | apache2-baf4f92af0f97d8bc72460446d2384d849ae0cf3.tar.xz apache2-baf4f92af0f97d8bc72460446d2384d849ae0cf3.zip |
mod_cache: follow up to r1591328.
Define the cache_merge_headers_out() function to merge r->err_headers_out into
r->headers_out and add the ones from r->content_type/encoding if available.
Use it in ap_cache_cacheable_headers_out() where the same is done and in
cache_save_filter() where this has to be done before updating the entry.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1594643 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/cache')
-rw-r--r-- | modules/cache/cache_util.c | 25 | ||||
-rw-r--r-- | modules/cache/cache_util.h | 6 | ||||
-rw-r--r-- | modules/cache/mod_cache.c | 4 |
3 files changed, 23 insertions, 12 deletions
diff --git a/modules/cache/cache_util.c b/modules/cache/cache_util.c index cafbc16781..05cd3e09c9 100644 --- a/modules/cache/cache_util.c +++ b/modules/cache/cache_util.c @@ -1237,26 +1237,33 @@ CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_headers_out(request_rec *r) { apr_table_t *headers_out; - headers_out = apr_table_overlay(r->pool, r->headers_out, - r->err_headers_out); - - apr_table_clear(r->err_headers_out); - - headers_out = ap_cache_cacheable_headers(r->pool, headers_out, - r->server); + headers_out = ap_cache_cacheable_headers(r->pool, + cache_merge_headers_out(r), + r->server); cache_control_remove(r, cache_table_getm(r->pool, headers_out, "Cache-Control"), headers_out); + return headers_out; +} + +apr_table_t *cache_merge_headers_out(request_rec *r) +{ + apr_table_t *headers_out; + + headers_out = apr_table_overlay(r->pool, r->headers_out, + r->err_headers_out); + apr_table_clear(r->err_headers_out); + if (!apr_table_get(headers_out, "Content-Type") - && r->content_type) { + && r->content_type) { apr_table_setn(headers_out, "Content-Type", ap_make_content_type(r, r->content_type)); } if (!apr_table_get(headers_out, "Content-Encoding") - && r->content_encoding) { + && r->content_encoding) { apr_table_setn(headers_out, "Content-Encoding", r->content_encoding); } diff --git a/modules/cache/cache_util.h b/modules/cache/cache_util.h index 37c3ac3242..b845d2d27d 100644 --- a/modules/cache/cache_util.h +++ b/modules/cache/cache_util.h @@ -321,6 +321,12 @@ const char *cache_table_getm(apr_pool_t *p, const apr_table_t *t, */ char *cache_strqtok(char *str, const char *sep, char **last); +/** + * Merge err_headers_out into headers_out and add request's Content-Type and + * Content-Encoding if available. + */ +apr_table_t *cache_merge_headers_out(request_rec *r); + #ifdef __cplusplus } #endif diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index afa1980515..93bb9f7828 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -1449,9 +1449,7 @@ static apr_status_t cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) * here we want to keep the original headers in r->headers_out and * forward all of them to the client, including non-cacheable ones). */ - r->headers_out = apr_table_overlay(r->pool, r->headers_out, - r->err_headers_out); - apr_table_clear(r->err_headers_out); + r->headers_out = cache_merge_headers_out(r); /* Merge in our cached headers. However, keep any updated values. */ /* take output, overlay on top of cached */ |