]> granicus.if.org Git - apache/blobdiff - docs/manual/expr.xml
xforms
[apache] / docs / manual / expr.xml
index 07fbb667ac91f06096ce2faf0237707b6a1eba8d..cbf0d4e2d96354931f3f7e6ad1eeae5ef148fe54 100644 (file)
 <seealso><directive module="core" type="section">Else</directive></seealso>
 <seealso><directive module="mod_rewrite">RewriteCond</directive></seealso>
 <seealso><directive module="mod_setenvif">SetEnvIfExpr</directive></seealso>
+<seealso><directive module="mod_headers">Header</directive></seealso>
+<seealso><directive module="mod_headers">RequestHeader</directive></seealso>
 <seealso><directive module="mod_filter">FilterProvider</directive></seealso>
 <seealso><a href="mod/mod_authz_core.html#reqexpr">Require expr</a></seealso>
 <seealso><directive module="mod_ssl">SSLRequire</directive></seealso>
+<seealso><directive module="mod_log_debug">LogMessage</directive></seealso>
 <seealso><module>mod_include</module></seealso>
 
   <section id="grammar">
-    <title>Grammar in BackusNaur Form notation</title>
-      <p><a href="http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form">BackusNaur Form</a> (BNF) is a notation
+    <title>Grammar in Backus-Naur Form notation</title>
+      <p><a href="http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form">Backus-Naur Form</a> (BNF) is a notation
       technique for context-free grammars, often used to describe the syntax of languages used in computing.
+      In most cases, expressions are used to express boolean values.
+      For these, the starting boint in the BNF is <code>expr</code>. However, a few directives
+      like <directive module="mod_log_debug">LogMessage</directive> accept expressions
+      that evaluate to a string value. For those, the starting boint in the BNF is <code>string</code>.
       </p>
 <blockquote>
 <pre>
@@ -131,8 +138,13 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
     <code>%{REMOTE_USER}</code> will not be set in this case.</p>
 
     <p>The following variables provide the values of the named HTTP request
-    headers. The values of other headers can be obtained witht the
-    <code>req</code> <a href="#functions">function</a>.</p>
+    headers. The values of other headers can be obtained with the
+    <code>req</code> <a href="#functions">function</a>. Using these
+    variables may cause the header name to be added to the Vary
+    header of the HTTP response, except where otherwise noted for the
+    directive accepting the expression. The <code>req_novary</code>
+    <a href="#functions">function</a> may be used to circumvent this
+    behavior.</p>
 
     <table border="1" style="zebra">
     <columnspec><column width="1"/></columnspec>
@@ -159,7 +171,7 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
     <tr><td><code>REQUEST_SCHEME</code></td>
         <td>The scheme part of the request's URI</td></tr>
     <tr><td><code>REQUEST_URI</code></td>
-        <td>The URI of the request</td></tr>
+        <td>The path part of the request's URI</td></tr>
     <tr><td><code>DOCUMENT_URI</code></td>
         <td>Same as REQUEST_URI</td></tr>
     <tr><td><code>REQUEST_FILENAME</code></td>
@@ -208,7 +220,20 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
         <td>The <directive module="core">ServerAdmin</directive> of
             the current vhost</td></tr>
     <tr><td><code>SERVER_PROTOCOL</code></td>
-        <td>The protocol used by the request</td></tr>
+        <td>The protocol used by the request (e.g. HTTP/1.1). In some types of
+            internal subrequests, this variable has the value
+            <code>INCLUDED</code>.</td></tr>
+    <tr><td><code>SERVER_PROTOCOL_VERSION</code></td>
+        <td>A number that encodes the HTTP version of the request:
+            <code>1000 * major + minor</code>. For example, <code>1001</code>
+            corresponds to HTTP/1.1 and <code>9</code> corresponds
+            to HTTP/0.9</td></tr>
+    <tr><td><code>SERVER_PROTOCOL_VERSION_MAJOR</code></td>
+        <td>The major version part of the HTTP version of the request,
+            e.g. <code>1</code> for HTTP/1.0</td></tr>
+    <tr><td><code>SERVER_PROTOCOL_VERSION_MINOR</code></td>
+        <td>The minor version part of the HTTP version of the request,
+            e.g. <code>0</code> for HTTP/1.0</td></tr>
     <tr><td><code>DOCUMENT_ROOT</code></td>
         <td>The <directive module="core">DocumentRoot</directive> of
             the current vhost</td></tr>
@@ -227,13 +252,16 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
         <td>"<code>on</code>" if the connection uses IPv6,
             "<code>off</code>" otherwise</td></tr>
     <tr><td><code>REQUEST_STATUS</code></td>
-        <td>The HTTP error status of the request<td></tr>
+        <td>The HTTP error status of the request</td></tr>
     <tr><td><code>REQUEST_LOG_ID</code></td>
         <td>The error log id of the request (see
             <directive module="core">ErrorLogFormat</directive>)</td></tr>
     <tr><td><code>CONN_LOG_ID</code></td>
         <td>The error log id of the connection (see
             <directive module="core">ErrorLogFormat</directive>)</td></tr>
+    <tr><td><code>CONN_REMOTE_ADDR</code></td>
+        <td>The peer IP address of the connection (see the
+            <module>mod_remoteip</module> module)</td></tr>
 
     </table>
 
@@ -368,6 +396,9 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
     <tr><td><code>-f</code></td>
         <td>The argument is treated as a filename.
             True if the file exists and is regular file</td><td>yes</td></tr>
+    <tr><td><code>-s</code></td>
+        <td>The argument is treated as a filename.
+            True if the file exists and is not empty</td><td>yes</td></tr>
     <tr><td><code>-L</code></td>
         <td>The argument is treated as a filename.
             True if the file exists and is symlink</td><td>yes</td></tr>
@@ -416,7 +447,11 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
 
     <tr><th>Name</th><th>Description</th><th>Restricted</th></tr>
     <tr><td><code>req</code>, <code>http</code></td>
-        <td>Get HTTP request header</td><td></td></tr>
+        <td>Get HTTP request header; header names may be added to the Vary
+            header, see below</td><td></td></tr>
+    <tr><td><code>req_novary</code></td>
+        <td>Same as <code>req</code>, but header names will not be added to the
+            Vary header</td><td></td></tr>
     <tr><td><code>resp</code></td>
         <td>Get HTTP response header</td><td></td></tr>
     <tr><td><code>reqenv</code></td>
@@ -435,8 +470,8 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
     <tr><td><code>escape</code></td>
         <td>Escape special characters in %hex encoding</td><td></td></tr>
     <tr><td><code>unescape</code></td>
-        <td>Unescape %hex encoded string, leaving URL-special characters
-            encoded (XXX: describe better)</td><td></td></tr>
+        <td>Unescape %hex encoded string, leaving encoded slashes alone;
+            return empty string if %00 is found</td><td></td></tr>
     <tr><td><code>file</code></td>
         <td>Read contents from a file</td><td>yes</td></tr>
     <tr><td><code>filesize</code></td>
@@ -448,6 +483,12 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
     <p>The functions marked as "restricted" are not available in some modules
     like <module>mod_include</module>.</p>
 
+    <p>When the functions <code>req</code> or <code>http</code> are used,
+    the header name will automatically be added to the Vary header of the
+    HTTP response, except where otherwise noted for the directive accepting
+    the expression. The <code>req_novary</code> function can be used to
+    prevent names from being added to the Vary header.</p>
+
     <p>In addition to string-valued functions, there are also list-valued functions which
     take one string as argument and return a wordlist, i.e. a list of strings. The wordlist
     can be used with the special <code>-in</code> operator.
@@ -462,6 +503,29 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
 
 </section>
 
+<section id="examples">
+    
+       <title>Example expressions</title>
+       <p>The following examples show how expressions might be used to evaluate requests:</p>
+       <!-- This section should probably be extended with more, useful examples -->
+       <highlight language="config">
+# Compare the host name to example.com and redirect to www.example.com if it matches
+&lt;If "%{HTTP_HOST} == 'example.com'"&gt;
+    Redirect permanent / http://www.example.com
+&lt;/If&gt;
+
+# Force text/plain if requesting a file with the query string contains 'forcetext'
+&lt;If "%{QUERY_STRING} =~ /forcetext/"&gt;
+    ForceType text/plain
+&lt;/If&gt;
+
+# Only allow access to this content during business hours
+&lt;Directory "/foo/bar/business"&gt;
+    Require expr %{TIME_HOUR} -gt 9 &amp;&amp; %{TIME_HOUR} -lt 17 
+&lt;/Directory&gt;     
+       </highlight>
+</section>
+
 <section id="other">
     <title>Other</title>
 
@@ -494,4 +558,12 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
 
 </section>
 
+<section id="sslrequire">
+    <title>Comparison with SSLRequire</title>
+    <p>The <em>ap_expr</em> syntax is mostly a superset of the syntax of the
+    deprecated <directive module="mod_ssl">SSLRequire</directive> directive.
+    The differences are described in <directive
+    module="mod_ssl">SSLRequire</directive>'s documentation.</p>
+</section>
+
 </manualpage>