diff --git a/CHANGES b/CHANGES index 4a81e947aa..9e172201ff 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_rewrite, core: add the Vary header when a condition evaluates to true + and the related RewriteRule is used in a Directory context + (triggering an internal redirect). [Luca Toscano] + *) ab: Make the TLS layer aware that the underlying socket is nonblocking, and use/handle POLLOUT where needed to avoid busy IOs and recover write errors when appropriate. [Yann Ylavic] 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); diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index bc8f52d610..0b6c41ab27 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -5226,6 +5226,8 @@ static int hook_fixup(request_rec *r) } } + apr_table_setn(r->notes, "redirect-keeps-vary", ""); + /* now initiate the internal redirect */ rewritelog((r, 1, dconf->directory, "internal redirect with %s " "[INTERNAL REDIRECT]", r->filename));