expr.xml revision f28cb43e0ae51d68dee099bbf7ddbc84252cbd7e
1068N/A<?xml version="1.0" encoding="UTF-8" ?>
1068N/A<!DOCTYPE manualpage SYSTEM "/style/manualpage.dtd">
1068N/A<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
1068N/A<!-- $LastChangedRevision$ -->
1068N/A
1068N/A<!--
1068N/A Licensed to the Apache Software Foundation (ASF) under one or more
1068N/A contributor license agreements. See the NOTICE file distributed with
1068N/A this work for additional information regarding copyright ownership.
1068N/A The ASF licenses this file to You under the Apache License, Version 2.0
1068N/A (the "License"); you may not use this file except in compliance with
1068N/A the License. You may obtain a copy of the License at
1068N/A
1068N/A http://www.apache.org/licenses/LICENSE-2.0
1068N/A
1068N/A Unless required by applicable law or agreed to in writing, software
1068N/A distributed under the License is distributed on an "AS IS" BASIS,
1068N/A WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1068N/A See the License for the specific language governing permissions and
1068N/A limitations under the License.
1068N/A-->
1068N/A
1068N/A<manualpage metafile="expr.xml.meta">
1068N/A
1068N/A <title>Expressions in Apache HTTP Server</title>
1068N/A
1068N/A <summary>
1068N/A <p>Historically, there are several syntax variants for expressions used to express
1068N/A a condition in the different modules of the Apache HTTP Server.
1068N/A There is some ongoing effort to only use a single variant, called <em>ap_expr</em>,
1068N/A for all configuration directives.
1068N/A This document describes the <em>ap_expr</em> expression parser.
1068N/A </p>
1068N/A </summary>
1068N/A
1068N/A <section id="grammar">
1068N/A <title>Grammar in BNF notation</title>
1068N/A<blockquote>
1068N/A<pre>
1068N/Aexpr ::= "<strong>true</strong>" | "<strong>false</strong>"
1068N/A | "<strong>!</strong>" expr
1068N/A | expr "<strong>&amp;&amp;</strong>" expr
1068N/A | expr "<strong>||</strong>" expr
1068N/A | "<strong>(</strong>" expr "<strong>)</strong>"
1068N/A | comp
1068N/A
1068N/Acomp ::= stringcomp
1068N/A | integercomp
1068N/A | unaryop word
1068N/A | word binaryop word
1068N/A | word "<strong>in</strong>" "<strong>{</strong>" wordlist "<strong>}</strong>"
1068N/A | word "<strong>in</strong>" listfunction
1068N/A | word "<strong>=~</strong>" regex
1068N/A | word "<strong>!~</strong>" regex
1068N/A
1068N/A
1068N/Astringcomp ::= word "<strong>==</strong>" word | word "<strong>eq</strong>" word
1068N/A | word "<strong>!=</strong>" word | word "<strong>ne</strong>" word
1068N/A | word "<strong>&lt;</strong>" word | word "<strong>lt</strong>" word
1068N/A | word "<strong>&lt;=</strong>" word | word "<strong>le</strong>" word
1068N/A | word "<strong>&gt;</strong>" word | word "<strong>gt</strong>" word
1068N/A | word "<strong>&gt;=</strong>" word | word "<strong>ge</strong>" word
1068N/A
1068N/Aintegercomp ::= word "<strong>-eq</strong>" word | word "<strong>eq</strong>" word
1068N/A | word "<strong>-ne</strong>" word | word "<strong>ne</strong>" word
1068N/A | word "<strong>-lt</strong>" word | word "<strong>lt</strong>" word
1068N/A | word "<strong>-le</strong>" word | word "<strong>le</strong>" word
1068N/A | word "<strong>-gt</strong>" word | word "<strong>gt</strong>" word
1068N/A | word "<strong>-ge</strong>" word | word "<strong>ge</strong>" word
1068N/A
1068N/Awordlist ::= word
1068N/A | wordlist "<strong>,</strong>" word
1068N/A
1068N/Aword ::= word "<strong>.</strong>" word
1068N/A | digit
1068N/A | "<strong>'</strong>" string "<strong>'</strong>"
1068N/A | "<strong>"</strong>" string "<strong>"</strong>"
1068N/A | variable
1068N/A | function
1068N/A
1068N/Astring ::= stringpart
1068N/A | string stringpart
1068N/A
1068N/Astringpart ::= cstring
1068N/A | variable
1068N/A
1068N/Acstring ::= ...
1068N/Adigit ::= [0-9]+
1068N/A
1068N/Avariable ::= "<strong>%{</strong>" varname "<strong>}</strong>"
1068N/A | "<strong>%{</strong>" funcname "<strong>:</strong>" funcargs "<strong>}</strong>"
1068N/A
1068N/Afunction ::= funcname "<strong>(</strong>" word "<strong>)</strong>"
1068N/A
1068N/Alistfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
1068N/A</pre>
1068N/A</blockquote>
1068N/A
1068N/A</section>
1068N/A
1068N/A<section id="vars">
1068N/A <title>Variables</title>
1068N/A<p>XXX: not all vars are available in all request phases</p>
1068N/A
1068N/A <p>Request headers (XXX:see req function)</p>
1068N/A
1068N/A <table border="1" style="zebra">
1068N/A <columnspec><column width="1"/></columnspec>
1068N/A
1068N/A <tr><th>Name</th></tr>
1068N/A <tr><td><code>HTTP_ACCEPT</code></td></tr>
1068N/A <tr><td><code>HTTP_FORWARDED</code></td></tr>
1068N/A <tr><td><code>HTTP_HOST</code></td></tr>
1068N/A <tr><td><code>HTTP_PROXY_CONNECTION</code></td></tr>
1068N/A <tr><td><code>HTTP_REFERER</code></td></tr>
1068N/A <tr><td><code>HTTP_USER_AGENT</code></td></tr>
1068N/A
1068N/A </table>
1068N/A
1068N/A <p>Other request related variables</p>
1068N/A
1068N/A <table border="1" style="zebra">
1068N/A <columnspec><column width=".4"/><column width=".6"/></columnspec>
1068N/A
1068N/A <tr><th>Name</th><th>Description</th></tr>
1068N/A <tr><td><code>REQUEST_METHOD</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>REQUEST_SCHEME</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>REQUEST_URI</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>REQUEST_FILENAME</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>REMOTE_HOST</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>REMOTE_IDENT</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>REMOTE_USER</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>SERVER_ADMIN</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>SERVER_NAME</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>SERVER_PORT</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>SERVER_PROTOCOL</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>SCRIPT_FILENAME</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>PATH_INFO</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>QUERY_STRING</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>IS_SUBREQ</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>DOCUMENT_ROOT</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>AUTH_TYPE</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>THE_REQUEST</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>CONTENT_TYPE</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>HANDLER</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>REMOTE_ADDR</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>HTTPS</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>IPV6</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>REQUEST_LOG_ID</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>CONN_LOG_ID</code></td>
1068N/A <td></td></tr>
1068N/A
1068N/A </table>
1068N/A
1068N/A <p>Misc variables</p>
1068N/A
1068N/A <table border="1" style="zebra">
1068N/A <columnspec><column width=".4"/><column width=".6"/></columnspec>
1068N/A
1068N/A <tr><th>Name</th><th>Description</th></tr>
1068N/A <tr><td><code>TIME_YEAR</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>TIME_MON</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>TIME_DAY</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>TIME_HOUR</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>TIME_MIN</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>TIME_SEC</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>TIME_WDAY</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>TIME</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>SERVER_SOFTWARE</code></td>
1068N/A <td></td></tr>
1068N/A <tr><td><code>API_VERSION</code></td>
1068N/A <td></td></tr>
1068N/A </table>
1068N/A
1068N/A</section>
1068N/A
1068N/A<section id="binop">
1068N/A <title>Binary operators</title>
1068N/A
1068N/A <p>With the exception of some built-in comparison operators, binary
1068N/A operators have the form "<code>-[a-zA-Z][a-zA-Z0-9_]+</code>", i.e. a
1068N/A minus and at least two characters. The name is not case sensitive.
1068N/A Modules may register additional binary operators.</p>
1068N/A
1068N/A <table border="1" style="zebra">
1068N/A <columnspec><column width=".2"/><column width=".2"/><column width=".6"/></columnspec>
1068N/A
1068N/A <tr><th>Name</th><th>Alternative</th> <th>Description</th></tr>
1068N/A <tr><td><code>==</code></td>
1068N/A <td><code>=</code></td>
1068N/A <td>String equality</td></tr>
1068N/A <tr><td><code>!=</code></td>
1068N/A <td></td>
1068N/A <td>String inequality</td></tr>
1068N/A <tr><td><code>&lt;</code></td>
1068N/A <td></td>
1068N/A <td>String less than</td></tr>
1068N/A <tr><td><code>&lt;=</code></td>
1068N/A <td></td>
1068N/A <td>String less than or equal</td></tr>
1068N/A <tr><td><code>&gt;</code></td>
1068N/A <td></td>
1068N/A <td>String greater than</td></tr>
1068N/A <tr><td><code>&gt;=</code></td>
1068N/A <td></td>
1068N/A <td>String greater than or equal</td></tr>
1068N/A <tr><td><code>-eq</code></td>
1068N/A <td><code>eq</code></td>
1068N/A <td>Integer equality</td></tr>
1068N/A <tr><td><code>-ne</code></td>
1068N/A <td><code>ne</code></td>
1068N/A <td>Integer inequality</td></tr>
1068N/A <tr><td><code>-lt</code></td>
1068N/A <td><code>lt</code></td>
1068N/A <td>Integer less than</td></tr>
1068N/A <tr><td><code>-le</code></td>
1068N/A <td><code>le</code></td>
1068N/A <td>Integer less than or equal</td></tr>
1068N/A <tr><td><code>-gt</code></td>
1068N/A <td><code>gt</code></td>
1068N/A <td>Integer greater than</td></tr>
1068N/A <tr><td><code>-ge</code></td>
1068N/A <td><code>ge</code></td>
1068N/A <td>Integer greater than or equal</td></tr>
1068N/A </table>
1068N/A
1068N/A</section>
1068N/A
1068N/A<section id="unnop">
1068N/A <title>Unary operators</title>
1068N/A
1068N/A <p>Unary operators have the form "<code>-[a-zA-Z]</code>", i.e. a
1068N/A minus and one character. The name <em>is</em> case sensitive.
1068N/A Modules may register additional unary operators.</p>
1068N/A
1068N/A <table border="1" style="zebra">
1068N/A <columnspec><column width=".2"/><column width=".2"/><column width=".6"/></columnspec>
1068N/A
1068N/A <tr><th>Name</th><th>Description</th></tr>
1068N/A <tr><td><code>-n</code></td>
1068N/A <td>String is not empty</td></tr>
1068N/A <tr><td><code>-z</code></td>
1068N/A <td>String is empty</td></tr>
1068N/A </table>
1068N/A
1068N/A</section>
1068N/A
1068N/A<section id="functions">
1068N/A <title>Functions</title>
1068N/A
1068N/A <p>Normal string-valued functions take one string as argument and return
1068N/A a string. Functions names are not case sensitive.
1068N/A Modules may register additional functions.</p>
1068N/A
1068N/A <table border="1" style="zebra">
1068N/A <columnspec><column width=".2"/><column width=".8"/></columnspec>
1068N/A
1068N/A <tr><th>Name</th><th>Description</th></tr>
1068N/A <tr><td><code>req</code>, <code>http</code></td>
1068N/A <td>Get HTTP request header</td></tr>
1068N/A <tr><td><code>resp</code></td>
1068N/A <td>Get HTTP response header</td></tr>
1068N/A <tr><td><code>reqenv</code></td>
1068N/A <td>Lookup request environment variable</td></tr>
1068N/A <tr><td><code>osenv</code></td>
1068N/A <td>Lookup operating system environment variable</td></tr>
1068N/A <tr><td><code>note</code></td>
1068N/A <td>Lookup request environment variable</td></tr>
1068N/A <tr><td><code>env</code></td>
1068N/A <td>Return first match of <code>note</code>, <code>reqenv</code>,
1068N/A <code>osenv</code></td></tr>
1068N/A <tr><td><code>tolower</code></td>
1068N/A <td>Convert string to lower case</td></tr>
1068N/A <tr><td><code>toupper</code></td>
1068N/A <td>Convert string to uppser case</td></tr>
1068N/A <tr><td><code>escape</code></td>
1068N/A <td>Escape special characters in %hex encoding</td></tr>
1068N/A <tr><td><code>unescape</code></td>
1068N/A <td>Unescape %hex encoded string, leaving URL-special characters encoded (XXX: describe better)</td></tr>
1068N/A <tr><td><code>file</code></td>
1068N/A <td>Read contents from a file</td></tr>
1068N/A </table>
1068N/A
1068N/A <p>In addition to string-valued functions, there are also list-valued functions which
1068N/A take one string as argument and return a wordlist, i.e. a list of strings. The wordlist
1068N/A can be used with the special <code>-in</code> operator.
1068N/A Functions names are not case sensitive.
1068N/A Modules may register additional functions.</p>
1068N/A
1068N/A <p>There are no built-in list-valued functions. <module>mod_ssl</module>'s
1068N/A <directive module="mod_ssl">SSLRequire</directive> provides
1068N/A <code>PeerExtList</code>.</p>
1068N/A
1068N/A</section>
1068N/A
1068N/A</manualpage>
1068N/A