]> granicus.if.org Git - apache/commitdiff
Merge r1808746, r1809028 from trunk:
authorYann Ylavic <ylavic@apache.org>
Fri, 13 Oct 2017 08:42:57 +0000 (08:42 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 13 Oct 2017 08:42:57 +0000 (08:42 +0000)
mod_rewrite/core: avoid the 'Vary: Host' header

In PR 58231 is was brought up that httpd adds the
Vary: Host header whenever a condition is set to true
in mod_rewrite or in an <If> block.

The https://tools.ietf.org/html/rfc7231#section-7.1.4
section seems to disallow this use case:

"The "Vary" header field in a response describes "
"what parts of a request message, "
"aside from the method, Host header field, [...]"

I had a chat with the folks in #traffic-server and
they don't see much point in having a Vary: Host header,
plus it was reported that Varnish doesn't like it very
much (namely it does not cache the response when
it sees the header, links of the report in the PR).

I don't see much value in this behavior of httpd so
I am inclined to remove this response header value,
but I'd be glad to get a more experienced opinion.

mod_rewrite,core: avoid Vary:Host (part 2)

This is a follow up of r1808746 after a chat
with Yann on dev@:

- the HTTP:Host variable suffers from the same problem
- the strcasecmp should be used to allow case-sensitive
  comparisons.
- in mod_rewrite is less cumbersome and more clean to just
  make the Host header check in lookup_header, so it will
  be automatically picked up by every part of the code
  that uses it. It shouldn't be a relevant overhead for
  mod_rewrite.

Submitted by: elukey
Reviewed by: elukey, ylavic, wrowe

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1812083 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/mappers/mod_rewrite.c
server/util_expr_eval.c

diff --git a/CHANGES b/CHANGES
index 401c3ca2a76787c45b33522e718ed8027ef705ea..da1936628821fd724b80b60954b6bf574b043198 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.4.29
 
+  *) mod_rewrite, core: Avoid the 'Vary: Host' response header when HTTP_HOST
+     is used in a condition that evaluates to true. PR 58231 [Luca Toscano]
+
   *) mod_http2: v0.10.12, removed optimization for mutex handling in bucket
      beams that could lead to assertion failure in edge cases.
      [Stefan Eissing] 
diff --git a/STATUS b/STATUS
index bc444e1f55ed4d208f6cba4017587542c3283563..d7ca61c81e40718412d7f6d3dbada059c7e1f911 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -128,13 +128,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-   *) mod_rewrite,core: Avoid the 'Vary: Host' response header when HTTP_HOST
-                        is used in a condition that evaluates to true.
-      trunk patch: http://svn.apache.org/r1808746
-                   http://svn.apache.org/r1809028
-      2.4.x patch: svn merge -c 1808746,1809028 ^/httpd/httpd/trunk .
-      +1: elukey, ylavic, wrowe
-
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
index b5c73f79354143ff61713bd0b167f0ab7f6dbe92..05414c49ccb0f1c40294d2506b597999098a25c2 100644 (file)
@@ -1802,7 +1802,10 @@ static const char *lookup_header(const char *name, rewrite_ctx *ctx)
 {
     const char *val = apr_table_get(ctx->r->headers_in, name);
 
-    if (val) {
+    /* Skip the 'Vary: Host' header combination
+     * as indicated in rfc7231 section-7.1.4
+     */
+    if (val && strcasecmp(name, "Host") != 0) {
         ctx->vary_this = ctx->vary_this
                          ? apr_pstrcat(ctx->r->pool, ctx->vary_this, ", ",
                                        name, NULL)
index b1cb9235d1cb9a5632a16f72a9487b57a39ffaef..a24eaef67bd3ce7159a212bb0ecb3a1378b4663d 100644 (file)
@@ -1001,7 +1001,12 @@ static const char *req_table_func(ap_expr_eval_ctx_t *ctx, const void *data,
         t = ctx->r->headers_in;
     else {                          /* req, http */
         t = ctx->r->headers_in;
-        add_vary(ctx, arg);
+        /* Skip the 'Vary: Host' header combination
+         * as indicated in rfc7231 section-7.1.4
+         */
+        if (strcasecmp(arg, "Host")){
+            add_vary(ctx, arg);
+        }
     }
     return apr_table_get(t, arg);
 }
@@ -1467,7 +1472,12 @@ static const char *req_header_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
         return "";
 
     name = req_header_header_names[index];
-    add_vary(ctx, name);
+    /* Skip the 'Vary: Host' header combination
+     * as indicated in rfc7231 section-7.1.4
+     */
+    if (strcasecmp(name, "Host")){
+        add_vary(ctx, name);
+    }
     return apr_table_get(ctx->r->headers_in, name);
 }