From 6c57e61b1b493dafeb547d2ed78aa0859f9744cf Mon Sep 17 00:00:00 2001 From: Stefan Fritsch Date: Fri, 4 Nov 2011 07:27:07 +0000 Subject: [PATCH] Unify syntax of config directives taking an expression as optional contition argument git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1197413 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 6 ++++++ docs/manual/mod/mod_headers.xml | 22 +++++++++++----------- docs/manual/mod/mod_log_config.xml | 16 +++++++++------- docs/manual/mod/mod_log_debug.xml | 8 ++++---- modules/loggers/mod_log_debug.c | 4 ++-- modules/metadata/mod_headers.c | 8 ++++++-- 6 files changed, 38 insertions(+), 26 deletions(-) diff --git a/CHANGES b/CHANGES index 009b56d2fc..8e02fb298b 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,12 @@ Changes with Apache 2.3.15 PR 51714. [Stefan Fritsch, Jim Jagielski, Ruediger Pluem, Eric Covener, ] + *) mod_log_debug: Rename optional argument from if= to expr=, to be more + in line with other config directives. [Stefan Fritsch] + + *) mod_headers: Require an expression to be specified with expr=, to be more + in line with other config directives. [Stefan Fritsch] + *) mod_substitute: To prevent overboarding memory usage, limit line length to 1MB. [Stefan Fritsch] diff --git a/docs/manual/mod/mod_headers.xml b/docs/manual/mod/mod_headers.xml index 837573939b..9c80f74921 100644 --- a/docs/manual/mod/mod_headers.xml +++ b/docs/manual/mod/mod_headers.xml @@ -184,7 +184,7 @@ headers
  • Set a test cookie if and only if the client didn't send us a cookie - Header set Set-Cookie testcookie !$req{Cookie} + Header set Set-Cookie testcookie "expr=-z %{req:Cookie}"
  • @@ -273,15 +273,15 @@ headers
    early
    Specifies early processing.
    -
    env=[!]varname
    +
    env=[!]varname
    The directive is applied if and only if the environment variable varname exists. A ! in front of varname reverses the test, so the directive applies only if varname is unset.
    -
    expr
    -
    An string that matches neither of the above is parsed as an - expression. Details of expression syntax and evaluation are - currently best documented on the mod_filter page.
    +
    expr=expression
    +
    The directive is applied if and only if expression + evaluates to true. Details of expression syntax and evaluation are + documented in the ap_expr documentation.

    Except in early mode, the @@ -447,15 +447,15 @@ headers

    early
    Specifies early processing.
    -
    env=[!]varname
    +
    env=[!]varname
    The directive is applied if and only if the environment variable varname exists. A ! in front of varname reverses the test, so the directive applies only if varname is unset.
    -
    expr
    -
    An string that matches neither of the above is parsed as an - expression. Details of expression syntax and evaluation are - currently best documented on the mod_filter page.
    +
    expr=expression
    +
    The directive is applied if and only if expression + evaluates to true. Details of expression syntax and evaluation are + documented in the ap_expr documentation.

    Except in early mode, the diff --git a/docs/manual/mod/mod_log_config.xml b/docs/manual/mod/mod_log_config.xml index c7d260588b..1943d5c266 100644 --- a/docs/manual/mod/mod_log_config.xml +++ b/docs/manual/mod/mod_log_config.xml @@ -388,7 +388,8 @@ Sets filename and format of log file CustomLog file|pipe format|nickname -[env=[!]environment-variable] +[env=[!]environment-variable| +expr=expression] server configvirtual host @@ -445,12 +446,13 @@

    The third argument is optional and controls whether or - not to log a particular request based on the - presence or absence of a particular variable in the server - environment. If the specified environment - variable is set for the request (or is not set, in the case - of a 'env=!name' clause), then the - request will be logged.

    + not to log a particular request. The condition can be the + presence or absence (in the case of a 'env=!name' + clause) of a particular variable in the server + environment. Alternatively, the condition + can be expressed as arbitrary boolean expression. If the condition is not satisfied, the request + will not be logged.

    Environment variables can be set on a per-request basis using the mod_setenvif diff --git a/docs/manual/mod/mod_log_debug.xml b/docs/manual/mod/mod_log_debug.xml index 3231a03f38..316346d90f 100644 --- a/docs/manual/mod/mod_log_debug.xml +++ b/docs/manual/mod/mod_log_debug.xml @@ -46,7 +46,7 @@ Log message if request to /foo/* is processed in a sub-request: <Location /foo/>
    -   LogMessage "subrequest to /foo/" hook=type_checker if=%{IS_SUBREQ}
    +   LogMessage "subrequest to /foo/" hook=type_checker expr=%{IS_SUBREQ}
    </Location>
    @@ -59,9 +59,9 @@ Log message if an IPv6 client causes a request timeout: LogMessage "IPv6 timeout from %{REMOTE_ADDR}" - "if=-T %{IPV6} && %{REQUEST_STATUS} = 408" + "expr=-T %{IPV6} && %{REQUEST_STATUS} = 408" - Note the placing of the double quotes for the if= argument. + Note the placing of the double quotes for the expr= argument.

  • @@ -85,7 +85,7 @@ Log userdefined message to error log LogMessage message -[hook=hook] [if=expression] +[hook=hook] [expr=expression] Unset directory diff --git a/modules/loggers/mod_log_debug.c b/modules/loggers/mod_log_debug.c index 2c6b6f2909..4ccf9c916f 100644 --- a/modules/loggers/mod_log_debug.c +++ b/modules/loggers/mod_log_debug.c @@ -221,8 +221,8 @@ static const char *cmd_log_message(cmd_parms *cmd, void *dconf_, const char *arg return apr_psprintf(cmd->pool, "Invalid hook name: %s", name); } } - else if (strncasecmp(args[i], "if=", 3) == 0) { - const char *expr = args[i] + 3; + else if (strncasecmp(args[i], "expr=", 5) == 0) { + const char *expr = args[i] + 5; entry->condition = ap_expr_parse_cmd(cmd, expr, AP_EXPR_FLAG_DONT_VARY, &err, NULL); diff --git a/modules/metadata/mod_headers.c b/modules/metadata/mod_headers.c index 52102f2296..5debe8662e 100644 --- a/modules/metadata/mod_headers.c +++ b/modules/metadata/mod_headers.c @@ -490,15 +490,19 @@ static APR_INLINE const char *header_inout_cmd(cmd_parms *cmd, } condition_var = envclause + 4; } - else { + else if (strncasecmp(envclause, "expr=", 5) == 0) { const char *err = NULL; - expr = ap_expr_parse_cmd(cmd, envclause, 0, &err, NULL); + expr = ap_expr_parse_cmd(cmd, envclause + 5, 0, &err, NULL); if (err) { return apr_pstrcat(cmd->pool, "Can't parse envclause/expression: ", err, NULL); } } + else { + return apr_pstrcat(cmd->pool, "Unknown parameter: ", envclause, + NULL); + } } if ((colon = ap_strchr_c(hdr, ':'))) { -- 2.40.0