]> granicus.if.org Git - apache/commitdiff
Support %{HANDLER} in ap_expr (required for mod_filter)
authorStefan Fritsch <sf@apache.org>
Sun, 7 Nov 2010 22:53:59 +0000 (22:53 +0000)
committerStefan Fritsch <sf@apache.org>
Sun, 7 Nov 2010 22:53:59 +0000 (22:53 +0000)
Update mod_filter docs

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

docs/manual/expr.xml
docs/manual/mod/mod_filter.xml
docs/manual/upgrading.xml
server/util_expr_eval.c

index 56a7909564f2d93f5ed09b1c959069bd02b4ec75..67fd7a47b74fb3c775601486e0dc07a722374108 100644 (file)
@@ -161,6 +161,8 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
         <td></td></tr>
     <tr><td><code>CONTENT_TYPE</code></td>
         <td></td></tr>
+    <tr><td><code>HANDLER</code></td>
+        <td></td></tr>
     <tr><td><code>REMOTE_ADDR</code></td>
         <td></td></tr>
     <tr><td><code>HTTPS</code></td>
index ab5b48727969936c2907a735dcdab98276f37098..2a9880d79d8fce62c734a732cab60e3f728248c9 100644 (file)
     headers, environment variables, or the Handler used by this request.
     Unlike earlier versions, mod_filter now supports complex expressions
     involving multiple criteria with AND / OR logic (&amp;&amp; / ||)
-    and brackets.</dd>
+    and brackets. The details of the expression syntax are described in
+    the <a href="../expr.html">ap_expr documentation</a>.</dd>
 
     <dt>Configure the Chain</dt>
     <dd>The above directives build components of a smart filter chain,
     more versatile <var>expression</var>.  In general, you can convert
     a match/dispatch pair to the two sides of an expression, using
     something like:</p>
-    <example>"dispatch = match"</example>
+    <example>"dispatch = 'match'"</example>
     <p>The Request headers, Response headers and Environment variables
-    are now interpreted from syntax <var>$req{foo}</var>,
-    <var>$resp{foo}</var> and <var>$env{foo}</var> respectively.
-    The variables <var>$handler</var> and <var>$Content-Type</var>
+    are now interpreted from syntax <var>%{req:foo}</var>,
+    <var>%{resp:foo}</var> and <var>%{env:foo}</var> respectively.
+    The variables <var>%{HANDLER}</var> and <var>%{CONTENT_TYPE}</var>
     are also supported.</p>
-    <p>Note that the match no longer supports integer comparisons
-    or substring matches.  The latter can be replaced by regular
-    expression matches.</p>
+    <p>Note that the match no longer support substring matches.  They can be
+    replaced by regular expression matches.</p>
 </section>
 
 <section id="examples"><title>Examples</title>
     <dd>A simple case of replacing <directive>AddOutputFilterByType</directive>
     <example>
       FilterDeclare SSI<br/>
-      FilterProvider SSI INCLUDES "$resp{Content-Type} = /^text\/html/"<br/>
+      FilterProvider SSI INCLUDES "%{CONTENT_TYPE} =~ m|^text/html|"<br/>
       FilterChain SSI
     </example>
     </dd>
     <dd>The same as the above but dispatching on handler (classic
     SSI behaviour; .shtml files get processed).
     <example>
-      FilterProvider SSI INCLUDES "Handler = server-parsed"<br/>
+      FilterProvider SSI INCLUDES "%{HANDLER} = 'server-parsed'"<br/>
       FilterChain SSI
     </example>
     </dd>
     Accept-Encoding header.  This filter runs with ftype CONTENT_SET.
     <example>
       FilterDeclare gzip CONTENT_SET<br/>
-      FilterProvider gzip inflate "$req{Accept-Encoding} != /gzip/"<br/>
+      FilterProvider gzip inflate "%{req:Accept-Encoding} !~ /gzip/"<br/>
       FilterChain gzip
     </example>
     </dd>
     <dd>Suppose we want to downsample all web images, and have filters
     for GIF, JPEG and PNG.
     <example>
-      FilterProvider unpack jpeg_unpack "$resp{Content-Type} = image/jpeg"<br/>
-      FilterProvider unpack gif_unpack "$resp{Content-Type} = image/gif"<br/>
-      FilterProvider unpack png_unpack "$resp{Content-Type} = image/png"<br/>
+      FilterProvider unpack jpeg_unpack "%{CONTENT_TYPE} = 'image/jpeg'"<br/>
+      FilterProvider unpack gif_unpack "%{CONTENT_TYPE} = 'image/gif'"<br/>
+      FilterProvider unpack png_unpack "%{CONTENT_TYPE} = 'image/png'"<br/>
       <br />
-      FilterProvider downsample downsample_filter "$resp{Content-Type} = /image\/(jpeg|gif|png)/"<br/>
+      FilterProvider downsample downsample_filter "%{CONTENT_TYPE} = m|^image/(jpeg|gif|png)|"<br/>
       FilterProtocol downsample "change=yes"<br/>
       <br />
-      FilterProvider repack jpeg_pack "$resp{Content-Type} = image/jpeg"<br/>
-      FilterProvider repack gif_pack "$resp{Content-Type} = image/gif"<br/>
-      FilterProvider repack png_pack "$resp{Content-Type} = image/png"<br/>
+      FilterProvider repack jpeg_pack "%{CONTENT_TYPE} = 'image/jpeg'"<br/>
+      FilterProvider repack gif_pack "%{CONTENT_TYPE} = 'image/gif'"<br/>
+      FilterProvider repack png_pack "%{CONTENT_TYPE} = 'image/png'"<br/>
       &lt;Location /image-filter&gt;<br/>
       <indent>
         FilterChain unpack downsample repack<br/>
     <code>ap_register_output_filter</code>.
     </p>
 
-    <p><var>expression</var> can be any of the following:</p>
-    <dl>
-      <dt><code><var>string</var></code></dt>
-      <dd>true if <var>string</var> is not empty</dd>
-
-      <dt><code><var>string1</var> = <var>string2</var><br />
-      <var>string1</var> == <var>string2</var><br />
-      <var>string1</var> != <var>string2</var></code></dt>
-
-      <dd><p>Compare <var>string1</var> with <var>string2</var>. If
-      <var>string2</var> has the form <code>/<var>string2</var>/</code>
-      then it is treated as a regular expression. Regular expressions are
-      implemented by the <a href="http://www.pcre.org">PCRE</a> engine and
-      have the same syntax as those in <a href="http://www.perl.com">perl
-      5</a>. Note that <code>==</code> is just an alias for <code>=</code>
-      and behaves exactly the same way.</p>
-      </dd>
-
-      <dt><code><var>string1</var> &lt; <var>string2</var><br />
-       <var>string1</var> &lt;= <var>string2</var><br />
-       <var>string1</var> &gt; <var>string2</var><br />
-       <var>string1</var> &gt;= <var>string2</var></code></dt>
-
-      <dd>Compare <var>string1</var> with <var>string2</var>. Note, that
-      strings are compared <em>literally</em> (using
-      <code>strcmp(3)</code>). Therefore the string "100" is less than
-      "20".</dd>
-
-      <dt><code>( <var>expression</var> )</code></dt>
-      <dd>true if <var>expression</var> is true</dd>
-
-      <dt><code>! <var>expression</var></code></dt>
-      <dd>true if <var>expression</var> is false</dd>
-
-      <dt><code><var>expression1</var> &amp;&amp;
-        <var>expression2</var></code></dt>
-      <dd>true if both <var>expression1</var> and
-      <var>expression2</var> are true</dd>
-
-      <dt><code><var>expression1</var> ||
-        <var>expression2</var></code></dt>
-      <dd>true if either <var>expression1</var> or
-      <var>expression2</var> is true</dd>
-    </dl>
+    <p><var>expression</var> is described in the
+    <a href="../expr.html">ap_expr documentation</a>.</p>
 
 </usage>
 </directivesynopsis>
index 15878eb4b587aa9e901520bc47f3a587feaf6f1e..1336306dfb8cbb0570c0afa821475a39c91f93a0 100644 (file)
         directive, review your configuration to make sure it is
         present in all the necessary directory contexts.</li>
 
+        <li><module>mod_filter</module>: <directive
+        module="filter">FilterProvider</directive> syntax has changed and
+        now uses a boolean expression to determine if a filter is applied.
+        </li>
+
       </ul>
     </section>
   </section>
index 2b80e73efb9de0a06ce074f3ae1523064319a48a..1901666fa295f8f6f7b9aa76e8bfca735e90d3a7 100644 (file)
@@ -888,6 +888,7 @@ static const char *request_var_names[] = {
     "AUTH_TYPE",                /* 16 */
     "THE_REQUEST",              /* 17 */
     "CONTENT_TYPE",             /* 18 */
+    "HANDLER",                  /* 19 */
     NULL
 };
 
@@ -938,6 +939,8 @@ static const char *request_var_fn(ap_expr_eval_ctx *ctx, const void *data)
         return r->the_request;
     case 18:
         return r->content_type;
+    case 19:
+        return r->handler;
     default:
         ap_assert(0);
         return NULL;