You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by el...@apache.org on 2017/10/10 17:41:37 UTC
svn commit: r1811744 - in /httpd/httpd/trunk: CHANGES
modules/http/http_request.c modules/mappers/mod_rewrite.c
Author: elukey
Date: Tue Oct 10 17:41:37 2017
New Revision: 1811744
URL: http://svn.apache.org/viewvc?rev=1811744&view=rev
Log:
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.
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/modules/http/http_request.c
httpd/httpd/trunk/modules/mappers/mod_rewrite.c
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1811744&r1=1811743&r2=1811744&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Oct 10 17:41:37 2017
@@ -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]
Modified: httpd/httpd/trunk/modules/http/http_request.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/http_request.c?rev=1811744&r1=1811743&r2=1811744&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http/http_request.c (original)
+++ httpd/httpd/trunk/modules/http/http_request.c Tue Oct 10 17:41:37 2017
@@ -523,6 +523,7 @@ static request_rec *internal_internal_re
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_re
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);
Modified: httpd/httpd/trunk/modules/mappers/mod_rewrite.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/mappers/mod_rewrite.c?rev=1811744&r1=1811743&r2=1811744&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/mappers/mod_rewrite.c (original)
+++ httpd/httpd/trunk/modules/mappers/mod_rewrite.c Tue Oct 10 17:41:37 2017
@@ -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));