diff options
author | Luca Toscano <elukey@apache.org> | 2017-10-10 19:41:37 +0200 |
---|---|---|
committer | Luca Toscano <elukey@apache.org> | 2017-10-10 19:41:37 +0200 |
commit | aeaabea3c29b0b00dfd59c89a4b478db1e5e5285 (patch) | |
tree | eb3ac71801f711352849d458e5f09d6f9b3137c2 /modules/http | |
parent | Rebuild. (diff) | |
download | apache2-aeaabea3c29b0b00dfd59c89a4b478db1e5e5285.tar.xz apache2-aeaabea3c29b0b00dfd59c89a4b478db1e5e5285.zip |
core, mod_rewrite: introduce the 'redirect-keeps-vary' note
to allow proper Vary header insertion when
dealing with a RewriteRule in a directory
context.
This change is an attempt to fix a long standing problem,
brought up while working on PR 58231. Our documentation clearly
states the following:
"If a HTTP header is used in a condition this header is added
to the Vary header of the response in case the condition
evaluates to true for the request."
This is currently not true for RewriteCond/Rules working in
a directory context, since when an internal redirect happens
all the outstanding response headers get dropped.
There might be a better solution so I am looking forward to
hear more opinions and comments. My goal for a delicate change
like this one would be to affect the least amount of configurations
possible, without triggering unwanted side effects.
If the solution is good for everybody tests will be written
in the suite asap.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1811744 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/http')
-rw-r--r-- | modules/http/http_request.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/http/http_request.c b/modules/http/http_request.c index 2eff6f4e13..85c65707a2 100644 --- a/modules/http/http_request.c +++ b/modules/http/http_request.c @@ -523,6 +523,7 @@ static request_rec *internal_internal_redirect(const char *new_uri, request_rec *r) { int access_status; request_rec *new; + const char *vary_header; if (ap_is_recursion_limit_exceeded(r)) { ap_die(HTTP_INTERNAL_SERVER_ERROR, r); @@ -586,6 +587,16 @@ static request_rec *internal_internal_redirect(const char *new_uri, if (location) apr_table_setn(new->headers_out, "Location", location); } + + /* A module (like mod_rewrite) can force an internal redirect + * to carry over the Vary header (if present). + */ + if (apr_table_get(r->notes, "redirect-keeps-vary")) { + if((vary_header = apr_table_get(r->headers_out, "Vary"))) { + apr_table_setn(new->headers_out, "Vary", vary_header); + } + } + new->err_headers_out = r->err_headers_out; new->trailers_out = apr_table_make(r->pool, 5); new->subprocess_env = rename_original_env(r->pool, r->subprocess_env); |