]> granicus.if.org Git - apache/blobdiff - docs/manual/expr.html.en
xforms
[apache] / docs / manual / expr.html.en
index 227b1332d6ec4e284ab82045f44cd82513dcbb41..82f5aaea851a26921275697d425e64af1f774b0e 100644 (file)
@@ -14,7 +14,7 @@
 
 <link href="./images/favicon.ico" rel="shortcut icon" /></head>
 <body id="manual-page"><div id="page-header">
-<p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
+<p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
 <p class="apache">Apache HTTP Server Version 2.5</p>
 <img alt="" src="./images/feather.gif" /></div>
 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
 <li><img alt="" src="./images/down.gif" /> <a href="#examples">Example expressions</a></li>
 <li><img alt="" src="./images/down.gif" /> <a href="#other">Other</a></li>
 <li><img alt="" src="./images/down.gif" /> <a href="#sslrequire">Comparison with SSLRequire</a></li>
-</ul><h3>See also</h3><ul class="seealso"><li><code class="directive"><a href="./mod/core.html#if">&lt;If&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#elseif">&lt;ElseIf&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#else">&lt;Else&gt;</a></code></li><li><code class="directive"><a href="./mod/mod_rewrite.html#rewritecond">RewriteCond</a></code></li><li><code class="directive"><a href="./mod/mod_setenvif.html#setenvifexpr">SetEnvIfExpr</a></code></li><li><code class="directive"><a href="./mod/mod_headers.html#header">Header</a></code></li><li><code class="directive"><a href="./mod/mod_headers.html#requestheader">RequestHeader</a></code></li><li><code class="directive"><a href="./mod/mod_filter.html#filterprovider">FilterProvider</a></code></li><li><a href="mod/mod_authz_core.html#reqexpr">Require expr</a></li><li><code class="directive"><a href="./mod/mod_ssl.html#sslrequire">SSLRequire</a></code></li><li><code class="directive"><a href="./mod/mod_log_debug.html#logmessage">LogMessage</a></code></li><li><code class="module"><a href="./mod/mod_include.html">mod_include</a></code></li></ul></div>
+</ul><h3>See also</h3><ul class="seealso"><li><code class="directive"><a href="./mod/core.html#if">&lt;If&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#elseif">&lt;ElseIf&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#else">&lt;Else&gt;</a></code></li><li><code class="directive"><a href="./mod/mod_rewrite.html#rewritecond">RewriteCond</a></code></li><li><code class="directive"><a href="./mod/mod_setenvif.html#setenvifexpr">SetEnvIfExpr</a></code></li><li><code class="directive"><a href="./mod/mod_headers.html#header">Header</a></code></li><li><code class="directive"><a href="./mod/mod_headers.html#requestheader">RequestHeader</a></code></li><li><code class="directive"><a href="./mod/mod_filter.html#filterprovider">FilterProvider</a></code></li><li><a href="mod/mod_authz_core.html#reqexpr">Require expr</a></li><li><code class="directive"><a href="./mod/mod_ssl.html#sslrequire">SSLRequire</a></code></li><li><code class="directive"><a href="./mod/mod_log_debug.html#logmessage">LogMessage</a></code></li><li><code class="module"><a href="./mod/mod_include.html">mod_include</a></code></li></ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="grammar" id="grammar">Grammar in Backus-Naur Form notation</a></h2>
     
       <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 <code class="directive"><a href="./mod/mod_log_debug.html#logmessage">LogMessage</a></code> 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 +135,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 class="bordered"><tr class="header"><th>Name</th></tr>
 <tr><td><code>HTTP_ACCEPT</code></td></tr>
@@ -201,33 +210,46 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
         <td>The <code class="directive"><a href="./mod/core.html#serveradmin">ServerAdmin</a></code> of
             the current vhost</td></tr>
 <tr><td><code>SERVER_PROTOCOL</code></td>
-        <td>The protocol used by the request</td></tr>
-<tr class="odd"><td><code>DOCUMENT_ROOT</code></td>
+        <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 class="odd"><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 class="odd"><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 <code class="directive"><a href="./mod/core.html#documentroot">DocumentRoot</a></code> of
             the current vhost</td></tr>
-<tr><td><code>AUTH_TYPE</code></td>
+<tr class="odd"><td><code>AUTH_TYPE</code></td>
         <td>The configured <code class="directive"><a href="./mod/mod_authn_core.html#authtype">AuthType</a></code>
             (e.g. "<code>basic</code>")</td></tr>
-<tr class="odd"><td><code>CONTENT_TYPE</code></td>
+<tr><td><code>CONTENT_TYPE</code></td>
         <td>The content type of the response</td></tr>
-<tr><td><code>HANDLER</code></td>
+<tr class="odd"><td><code>HANDLER</code></td>
         <td>The name of the <a href="handler.html">handler</a> creating
             the response</td></tr>
-<tr class="odd"><td><code>HTTPS</code></td>
+<tr><td><code>HTTPS</code></td>
         <td>"<code>on</code>" if the request uses https,
             "<code>off</code>" otherwise</td></tr>
-<tr><td><code>IPV6</code></td>
+<tr class="odd"><td><code>IPV6</code></td>
         <td>"<code>on</code>" if the connection uses IPv6,
             "<code>off</code>" otherwise</td></tr>
-<tr class="odd"><td><code>REQUEST_STATUS</code></td>
+<tr><td><code>REQUEST_STATUS</code></td>
         <td>The HTTP error status of the request</td></tr>
-<tr><td><code>REQUEST_LOG_ID</code></td>
+<tr class="odd"><td><code>REQUEST_LOG_ID</code></td>
         <td>The error log id of the request (see
             <code class="directive"><a href="./mod/core.html#errorlogformat">ErrorLogFormat</a></code>)</td></tr>
-<tr class="odd"><td><code>CONN_LOG_ID</code></td>
+<tr><td><code>CONN_LOG_ID</code></td>
         <td>The error log id of the connection (see
             <code class="directive"><a href="./mod/core.html#errorlogformat">ErrorLogFormat</a></code>)</td></tr>
-<tr><td><code>CONN_REMOTE_ADDR</code></td>
+<tr class="odd"><td><code>CONN_REMOTE_ADDR</code></td>
         <td>The peer IP address of the connection (see the
             <code class="module"><a href="./mod/mod_remoteip.html">mod_remoteip</a></code> module)</td></tr>
 </table>
@@ -399,30 +421,34 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
 
     <table class="bordered"><tr class="header"><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 /></tr>
-<tr class="odd"><td><code>resp</code></td>
+        <td>Get HTTP request header; header names may be added to the Vary
+            header, see below</td><td /></tr>
+<tr class="odd"><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 /></tr>
+<tr><td><code>resp</code></td>
         <td>Get HTTP response header</td><td /></tr>
-<tr><td><code>reqenv</code></td>
+<tr class="odd"><td><code>reqenv</code></td>
         <td>Lookup request environment variable</td><td /></tr>
-<tr class="odd"><td><code>osenv</code></td>
+<tr><td><code>osenv</code></td>
         <td>Lookup operating system environment variable</td><td /></tr>
-<tr><td><code>note</code></td>
+<tr class="odd"><td><code>note</code></td>
         <td>Lookup request note</td><td /></tr>
-<tr class="odd"><td><code>env</code></td>
+<tr><td><code>env</code></td>
         <td>Return first match of <code>note</code>, <code>reqenv</code>,
             <code>osenv</code></td><td /></tr>
-<tr><td><code>tolower</code></td>
+<tr class="odd"><td><code>tolower</code></td>
         <td>Convert string to lower case</td><td /></tr>
-<tr class="odd"><td><code>toupper</code></td>
+<tr><td><code>toupper</code></td>
         <td>Convert string to uppser case</td><td /></tr>
-<tr><td><code>escape</code></td>
+<tr class="odd"><td><code>escape</code></td>
         <td>Escape special characters in %hex encoding</td><td /></tr>
-<tr class="odd"><td><code>unescape</code></td>
+<tr><td><code>unescape</code></td>
         <td>Unescape %hex encoded string, leaving encoded slashes alone;
             return empty string if %00 is found</td><td /></tr>
-<tr><td><code>file</code></td>
+<tr class="odd"><td><code>file</code></td>
         <td>Read contents from a file</td><td>yes</td></tr>
-<tr class="odd"><td><code>filesize</code></td>
+<tr><td><code>filesize</code></td>
         <td>Return size of a file (or 0 if file does not exist or is not
             regular file)</td><td>yes</td></tr>
 </table>
@@ -430,6 +456,12 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
     <p>The functions marked as "restricted" are not available in some modules
     like <code class="module"><a href="./mod/mod_include.html">mod_include</a></code>.</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.
@@ -449,26 +481,23 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
        
        <p>The following examples show how expressions might be used to evaluate requests:</p>
        
-       <div class="example"><p><code>
-       # Compare the host name to example.com and redirect to www.example.com if it matches<br />
-       &lt;If "%{HTTP_HOST} == 'example.com'"&gt;<br />
-       <span class="indent">
-               Redirect permanent / http://www.example.com<br />
-       </span>
-       &lt;/If&gt;<br /><br />
-       # Force text/plain if requesting a file with the query string contains 'forcetext'<br />
-       &lt;If "%{QUERY_STRING} =~ /forcetext/"&gt;<br />
-       <span class="indent">
-               ForceType text/plain<br />
-       </span>
-       &lt;/If&gt;<br /><br />
-       # Only allow access to this content during business hours<br />
-       &lt;Directory "/foo/bar/business"&gt;<br />
-       <span class="indent">
-               Require expr %{TIME_HOUR} &gt;= 9 &amp;&amp; %{TIME_HOUR} &lt;= 17 <br />
-       </span>
-       &lt;/Directory&gt;      
-       </code></p></div>
+       <pre class="prettyprint lang-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;     
+       </pre>
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="other" id="other">Other</a></h2>
@@ -509,11 +538,28 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
 <div class="bottomlang">
 <p><span>Available Languages: </span><a href="./en/expr.html" title="English">&nbsp;en&nbsp;</a> |
 <a href="./fr/expr.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
-</div><div id="footer">
-<p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
-<p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div><script type="text/javascript">
-    if (typeof(prettyPrint) !== undefined) {
-        prettyPrint();
+</div><div class="top"><a href="#page-header"><img src="./images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
+<script type="text/javascript"><!--//--><![CDATA[//><!--
+var comments_shortname = 'httpd';
+var comments_identifier = 'http://httpd.apache.org/docs/trunk/expr.html';
+(function(w, d) {
+    if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
+        d.write('<div id="comments_thread"><\/div>');
+        var s = d.createElement('script');
+        s.type = 'text/javascript';
+        s.async = true;
+        s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
+        (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
     }
-</script>
+    else {
+        d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
+    }
+})(window, document);
+//--><!]]></script></div><div id="footer">
+<p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
+<p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
+if (typeof(prettyPrint) !== 'undefined') {
+    prettyPrint();
+}
+//--><!]]></script>
 </body></html>
\ No newline at end of file