You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2007/12/08 20:32:41 UTC

svn commit: r602535 - in /httpd/httpd/branches/2.2.x: CHANGES STATUS docs/manual/mod/mod_rewrite.xml modules/mappers/mod_rewrite.c

Author: jim
Date: Sat Dec  8 11:32:40 2007
New Revision: 602535

URL: http://svn.apache.org/viewvc?rev=602535&view=rev
Log:
Merge r574201, r574684 from trunk:

* Also set the Vary header if a rewrite condition is true and uses a HTTP
  header, but all remaining rewrite conditions are skipped due to the [OR]
  flag.


* Add the novary flag to RewriteCond in order to prevent the appending
  of HTTP headers used in a rewrite condition to the Vary header of
  the response.

Submitted by: rpluem
Reviewed by: jim

Modified:
    httpd/httpd/branches/2.2.x/CHANGES
    httpd/httpd/branches/2.2.x/STATUS
    httpd/httpd/branches/2.2.x/docs/manual/mod/mod_rewrite.xml
    httpd/httpd/branches/2.2.x/modules/mappers/mod_rewrite.c

Modified: httpd/httpd/branches/2.2.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/CHANGES?rev=602535&r1=602534&r2=602535&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Sat Dec  8 11:32:40 2007
@@ -1,6 +1,9 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.2.7
 
+  *) mod_rewrite: Add the novary flag to RewriteCond.
+     [Ruediger Pluem] 
+
   *) core: Change etag generation to produce identical results on
      32-bit and 64-bit platforms.  PR 40064.  [Joe Orton]
 

Modified: httpd/httpd/branches/2.2.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/STATUS?rev=602535&r1=602534&r2=602535&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/STATUS (original)
+++ httpd/httpd/branches/2.2.x/STATUS Sat Dec  8 11:32:40 2007
@@ -79,32 +79,6 @@
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  * mod_rewrite: Also set the Vary header if a rewrite condition is true and
-    uses a HTTP header, but all remaining rewrite conditions are skipped due
-    to the [OR] flag.
-    Trunk version of patch:
-       http://svn.apache.org/viewcvs.cgi?rev=574201&view=rev
-    Backport version for 2.2.x of patch:
-       Trunk version of patch works
-    +1: rpluem, niq
-    +0: jim: I'm curious that if this would result in some
-             "regressions" for some users who either depend on
-             the old behavior or have worked around it...
-        rpluem answers: If r574684 is backported (see below) these users can
-        fix it without workarounds and a clear and promised behaviour.
-        Relying on the above is relying on a buggy iundocumented behaviour,
-        but yes I do this sometimes by myself :-).
-    +1: jim: iff r574684 is also backported
-
-  * mod_rewrite: Add the novary flag to RewriteCond in order to prevent
-    the appending of HTTP headers used in a rewrite condition to the Vary
-    header of the response.
-    Trunk version of patch:
-       http://svn.apache.org/viewcvs.cgi?rev=574684&view=rev
-    Backport version for 2.2.x of patch:
-       Trunk version of patch works
-    +1: rpluem, jim, niq
-
   * server/protocol.c: Prevent 1-byte overflow on 8192 boundary in
     ap_vrprintf(). PR 43310
     trunk:

Modified: httpd/httpd/branches/2.2.x/docs/manual/mod/mod_rewrite.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/docs/manual/mod/mod_rewrite.xml?rev=602535&r1=602534&r2=602535&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/docs/manual/mod/mod_rewrite.xml (original)
+++ httpd/httpd/branches/2.2.x/docs/manual/mod/mod_rewrite.xml Sat Dec  8 11:32:40 2007
@@ -828,7 +828,15 @@
 	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
@@ -987,6 +995,16 @@
 
           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>

Modified: httpd/httpd/branches/2.2.x/modules/mappers/mod_rewrite.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/mappers/mod_rewrite.c?rev=602535&r1=602534&r2=602535&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/mappers/mod_rewrite.c (original)
+++ httpd/httpd/branches/2.2.x/modules/mappers/mod_rewrite.c Sat Dec  8 11:32:40 2007
@@ -130,6 +130,7 @@
 #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
@@ -3043,6 +3044,10 @@
              || 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);
     }
@@ -3744,6 +3749,12 @@
         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. */
@@ -3756,7 +3767,6 @@
                        && c->flags & CONDFLAG_ORNEXT) {
                     c = &conds[++i];
                 }
-                continue;
             }
         }
         else if (!rc) {