From: Bill Stoddard Date: Tue, 12 Jun 2001 17:06:04 +0000 (+0000) Subject: Extend mod_setenvif to support specifying regular expressions X-Git-Tag: 2.0.19~78 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e36b1ebae6a85cbbef2e3f35ba46ba0411bae2f1;p=apache Extend mod_setenvif to support specifying regular expressions on the SetEnvIf (and SetEnvIfNoCase) directive attribute field. Example: SetEnvIf ^TS* [a-z].* HAVE_TS will cause HAVE_TS to be set if any of the request headers begins with "TS" and has a value that begins with any character in the set [a-z]. [Bill Stoddard] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89353 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index d46cea2220..8a94136e63 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,11 @@ Changes with Apache 2.0.19-dev + *) Extend mod_setenvif to support specifying regular expressions + on the SetEnvIf (and SetEnvIfNoCase) directive attribute field. + Example: SetEnvIf ^TS* [a-z].* HAVE_TS + will cause HAVE_TS to be set if any of the request headers begins + with "TS" and has a value that begins with any character in the + set [a-z]. [Bill Stoddard] + *) httpd children now re-bind themselves to a random CPU on multiprocessor systems on AIX via bindprocessor() in 2.0. [Victor J. Orlikowski] diff --git a/docs/manual/mod/mod_setenvif.html b/docs/manual/mod/mod_setenvif.html index 34ee26ce61..53cca77a57 100644 --- a/docs/manual/mod/mod_setenvif.html +++ b/docs/manual/mod/mod_setenvif.html @@ -338,6 +338,12 @@ REL="Help" scope.

+ attribute may be a regular expression when used to match a request header. + If attribute is a regular expression and it doesn't match any of the + request's header names, then attribute is not tested against the request's + environment variable list. +

+

Example:

@@ -348,6 +354,8 @@ REL="Help"
    SetEnvIf Referer www\.mydomain\.com intra_site_referral
         :
    SetEnvIf object_is_image xbm XBIT_PROCESSING=1
+        :
+   SetEnvIf ^TS*  ^[a-z].*  HAVE_TS
   

The first three will set the environment variable object_is_image if the @@ -355,7 +363,11 @@ REL="Help" intra_site_referral if the referring page was somewhere on the www.mydomain.com Web site.

- +

+ The last example will set environment variable HAVE_TS if the request + contains any headers that begin with "TS" whose values begins with any character + in the set [a-z]. +


SetEnvIfNoCase directive diff --git a/modules/metadata/mod_setenvif.c b/modules/metadata/mod_setenvif.c index 05c64262c8..761fcc75ec 100644 --- a/modules/metadata/mod_setenvif.c +++ b/modules/metadata/mod_setenvif.c @@ -75,9 +75,10 @@ * SetEnvIf name regex var ... * * where name is either a HTTP request header name, or one of the - * special values (see below). The 'value' of the header (or the - * value of the special value from below) are compared against the - * regex argument. If this is a simple string, a simple sub-string + * special values (see below). 'name' may be a regex when it is used + * to specify an HTTP request header name. The 'value' of the header + & (or the value of the special value from below) are compared against + * the regex argument. If this is a simple string, a simple sub-string * match is performed. Otherwise, a request expression match is * done. If the value matches the string or regular expression, the * environment variables listed as var ... are set. Each var can @@ -113,6 +114,11 @@ * This could be written as: * * SetEnvIf remote_addr (127.0.0.1|192.168.10.) LOCAL + * + * To set HAVE_TS if the client request contains any header beginning + * with "TS" with a value beginning with a lower case alphabet: + * + * SetEnvIf ^TS* ^[a-z].* HAVE_TS */ #include "apr.h"