]> granicus.if.org Git - apache/commitdiff
* Add the novary flag to RewriteCond in order to prevent the appending
authorRuediger Pluem <rpluem@apache.org>
Tue, 11 Sep 2007 20:15:54 +0000 (20:15 +0000)
committerRuediger Pluem <rpluem@apache.org>
Tue, 11 Sep 2007 20:15:54 +0000 (20:15 +0000)
  of HTTP headers used in a rewrite condition to the Vary header of
  the response.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@574684 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/mod/mod_rewrite.xml
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index 01ac0bdcb09221e486f824f1df2ffd62ec566264..07f0d6cf5496de3460d7bdfe432502b337a18983 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 Changes with Apache 2.3.0
 [ When backported to 2.2.x, remove entry from this file ]
 
+  *) mod_rewrite: Add the novary flag to RewriteCond.
+     [Ruediger Pluem]
+
   *) Don't send spurious "100 Continue" response lines.
      PR 38014 [Basant Kumar Kukreja <basant.kukreja sun.com>]
 
index 317e0106a7a1fc72090e7ac1839cf587675ebdcf..b7649afc417331d7ffed726af0caac9b14a235e8 100644 (file)
@@ -848,7 +848,15 @@ Result:
        value of a header sent in the HTTP request.
         Example: <code>%{HTTP:Proxy-Connection}</code> is
         the value of the HTTP header
-        ``<code>Proxy-Connection:</code>''.</li>
+        ``<code>Proxy-Connection:</code>''.
+        <p>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
+        to true for the request. It is <strong>not</strong> added if the
+        condition evaluates to false for the request. Adding the HTTP header
+        to the Vary header of the response is needed for proper caching.</p>
+        <p>It has to be kept in mind that conditions follow a short circuit
+        logic in the case of the '<strong><code>ornext|OR</code></strong>' flag
+        so that certain conditions might not be evaluated at all.</p></li>
 
         <li>
         <code>%{LA-U:variable}</code> can be used for look-aheads which perform
@@ -1008,6 +1016,16 @@ RewriteRule ...some special stuff for any of these hosts...
           Without this flag you would have to write the condition/rule
           pair three times.
         </li>
+
+        <li>'<strong><code>novary|NV</code></strong>'
+        (<strong>n</strong>o <strong>v</strong>ary)<br />
+        If a HTTP header is used in the condition, this flag prevents
+        this header from being added to the Vary header of the response. <br />
+        Using this flag might break proper caching of the response if
+        the representation of this response varies on the value of this header.
+        So this flag should be only used if the meaning of the Vary header
+        is well understood.
+        </li>
       </ul>
       </li>
      </ol>
index 83d55ca4cf9b2ddc309cfae4349be36f9d184d21..e76b165f5720c9a1f3a1ecd95bdef28b7f65e000 100644 (file)
@@ -135,6 +135,7 @@ static void (*dbd_prepare)(server_rec*, const char*, const char*) = NULL;
 #define CONDFLAG_NOCASE             1<<1
 #define CONDFLAG_NOTMATCH           1<<2
 #define CONDFLAG_ORNEXT             1<<3
+#define CONDFLAG_NOVARY             1<<4
 
 #define RULEFLAG_NONE               1<<0
 #define RULEFLAG_FORCEREDIRECT      1<<1
@@ -3207,6 +3208,10 @@ static const char *cmd_rewritecond_setflag(apr_pool_t *p, void *_cfg,
              || strcasecmp(key, "OR") == 0    ) {
         cfg->flags |= CONDFLAG_ORNEXT;
     }
+    else if (   strcasecmp(key, "novary") == 0
+             || strcasecmp(key, "NV") == 0    ) {
+        cfg->flags |= CONDFLAG_NOVARY;
+    }
     else {
         return apr_pstrcat(p, "RewriteCond: unknown flag '", key, "'", NULL);
     }
@@ -3908,6 +3913,12 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
         rewritecond_entry *c = &conds[i];
 
         rc = apply_rewrite_cond(c, ctx);
+        /*
+         * Reset vary_this if the novary flag is set for this condition.
+         */
+        if (c->flags & CONDFLAG_NOVARY) {
+            ctx->vary_this = NULL;
+        }
         if (c->flags & CONDFLAG_ORNEXT) {
             if (!rc) {
                 /* One condition is false, but another can be still true. */