-*- coding: utf-8 -*-
Changes with Apache 2.4.19
+ *) core: Add expression support to SetHandler.
+ [Eric Covener]
*) core: Prevent a server crash in case of an invalid CONNECT request with
a custom error page for status code 400 that uses server side includes.
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- *) core: Add expression support to SetHandler (someone wanted this in
- a well-articulated serverfault post).
- trunk patch: http://svn.apache.org/r1725149
- http://svn.apache.org/r1725151
- http://svn.apache.org/r1726233
- http://svn.apache.org/r1729374
- 2.4.x patch: MMN/changes only: http://people.apache.org/~covener/patches/2.4.x-sethandler-expr-2.diff
- + http://svn.apache.org/r1729374
- +1: covener, jim, ylavic
-
*) core: introducing new hook "pre_close_connection" to give protocols other
than http/1.1 a chance to send one last frame before close.
Requires MMN bump
<name>SetHandler</name>
<description>Forces all matching files to be processed by a
handler</description>
-<syntax>SetHandler <var>handler-name</var>|None</syntax>
+<syntax>SetHandler <var>handler-name</var>|none|<var>expression</var></syntax>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context><context>.htaccess</context>
</contextlist>
<override>FileInfo</override>
+<compatibility>2.4.19 and later</compatibility>
<usage>
<p>When placed into an <code>.htaccess</code> file or a
</FilesMatch>
</highlight>
+ <p>String-valued expressions can be used to reference per-request
+ variables, including backreferences to named regular expressions:</p>
+
+ <highlight language="config">
+<LocationMatch ^/app/(?<sub>[^/]+)/>
+ SetHandler "proxy:unix:/var/run/app_%{env:MATCH_sub}.sock|fcgi://localhost:8080"
+</FilesMatch>
+ </highlight>
+
<p>You can override an earlier defined <directive>SetHandler</directive>
directive by using the value <code>None</code>.</p>
* ap_get_protocol(). Add HTTP_MISDIRECTED_REQUEST.
* Added ap_parse_token_list_strict() to httpd.h
* 20120211.52 (2.4.17-dev) Add master conn_rec* member in conn_rec.
+ * 20120211.53 (2.4.17-dev) Add epxr_hander to core_dir_config.
*/
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20120211
#endif
-#define MODULE_MAGIC_NUMBER_MINOR 52 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 53 /* 0...n */
/**
* Determine if the server's current MODULE_MAGIC_NUMBER is at least a
ap_regex_t *r;
const char *mime_type; /* forced with ForceType */
- const char *handler; /* forced with SetHandler */
+ const char *handler; /* forced by something other than SetHandler */
const char *output_filters; /* forced with SetOutputFilters */
const char *input_filters; /* forced with SetInputFilters */
int accept_path_info; /* forced with AcceptPathInfo */
*/
unsigned int cgi_pass_auth : 2;
unsigned int qualify_redirect_url :2;
-
+ ap_expr_info_t *expr_handler; /* forced with SetHandler */
} core_dir_config;
/* macro to implement off by default behaviour */
if (new->handler) {
conf->handler = new->handler;
}
+ if (new->expr_handler) {
+ conf->expr_handler = new->expr_handler;
+ }
if (new->output_filters) {
conf->output_filters = new->output_filters;
const char *arg_)
{
core_dir_config *dirconf = d_;
-
- if (arg_ == ap_strstr_c(arg_, "proxy:unix")) {
- dirconf->handler = arg_;
- }
- else {
- char *arg = apr_pstrdup(cmd->pool,arg_);
- ap_str_tolower(arg);
- dirconf->handler = arg;
+ const char *err;
+ dirconf->expr_handler = ap_expr_parse_cmd(cmd, arg_,
+ AP_EXPR_FLAG_STRING_RESULT,
+ &err, NULL);
+ if (err) {
+ return apr_pstrcat(cmd->pool,
+ "Can't parse expression : ", err, NULL);
}
-
return NULL;
}
if (conf->mime_type && strcmp(conf->mime_type, "none"))
ap_set_content_type(r, (char*) conf->mime_type);
- if (conf->handler && strcmp(conf->handler, "none"))
+ if (conf->expr_handler) {
+ const char *err;
+ const char *val;
+ val = ap_expr_str_exec(r, conf->expr_handler, &err);
+ if (err) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO()
+ "Can't evaluate handler expression: %s", err);
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+ if (strcmp(val, "none")) {
+ if (val != ap_strstr_c(val, "proxy:unix")) {
+ /* Retained for compatibility -- but not for UDS */
+ char *tmp = apr_pstrdup(r->pool, val);
+ ap_str_tolower(tmp);
+ r->handler = tmp;
+ }
+ else {
+ r->handler = val;
+ }
+ }
+ }
+ else if (conf->handler && strcmp(conf->handler, "none")) {
r->handler = conf->handler;
+ }
/* Deal with the poor soul who is trying to force path_info to be
* accepted within the core_handler, where they will let the subreq