1
0
mirror of https://github.com/apache/httpd.git synced 2026-01-06 09:01:14 +03:00

make trailing-slash-behaviour configurable

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@104154 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
André Malo
2004-07-03 16:43:39 +00:00
parent 50a54c9e9b
commit acbb11eddf
2 changed files with 30 additions and 3 deletions

View File

@@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev
[Remove entries to the current 2.0 section below, when backported]
*) mod_dir: the trailing-slash behaviour is now configurable using the
DirectorySlash directive. [Andr<64> Malo]
*) mod_proxy: multiple bugfixes, principally support cookies in
ProxyPassReverse, and don't canonicalise URL passed to backend.
Documentation correspondingly updated. [Nick Kew <nick webthing.com>]

View File

@@ -30,8 +30,15 @@
module AP_MODULE_DECLARE_DATA dir_module;
typedef enum {
SLASH_OFF = 0,
SLASH_ON,
SLASH_UNSET
} slash_cfg;
typedef struct dir_config_struct {
apr_array_header_t *index_names;
slash_cfg do_slash;
} dir_config_rec;
#define DIR_CMD_PERMS OR_INDEXES
@@ -47,10 +54,20 @@ static const char *add_index(cmd_parms *cmd, void *dummy, const char *arg)
return NULL;
}
static const char *configure_slash(cmd_parms *cmd, void *d_, int arg)
{
dir_config_rec *d = d_;
d->do_slash = arg ? SLASH_ON : SLASH_OFF;
return NULL;
}
static const command_rec dir_cmds[] =
{
AP_INIT_ITERATE("DirectoryIndex", add_index, NULL, DIR_CMD_PERMS,
"a list of file names"),
AP_INIT_FLAG("DirectorySlash", configure_slash, NULL, DIR_CMD_PERMS,
"On or Off"),
{NULL}
};
@@ -59,6 +76,7 @@ static void *create_dir_config(apr_pool_t *p, char *dummy)
dir_config_rec *new = apr_pcalloc(p, sizeof(dir_config_rec));
new->index_names = NULL;
new->do_slash = SLASH_UNSET;
return (void *) new;
}
@@ -69,6 +87,8 @@ static void *merge_dir_configs(apr_pool_t *p, void *basev, void *addv)
dir_config_rec *add = (dir_config_rec *)addv;
new->index_names = add->index_names ? add->index_names : base->index_names;
new->do_slash =
(add->do_slash == SLASH_UNSET) ? base->do_slash : add->do_slash;
return new;
}
@@ -95,11 +115,18 @@ static int fixup_dir(request_rec *r)
return DECLINED;
}
d = (dir_config_rec *)ap_get_module_config(r->per_dir_config,
&dir_module);
/* Redirect requests that are not '/' terminated */
if (r->uri[0] == '\0' || r->uri[strlen(r->uri) - 1] != '/')
{
char *ifile;
if (!d->do_slash) {
return DECLINED;
}
/* Only redirect non-get requests if we have no note to warn
* that this browser cannot handle redirs on non-GET requests
* (such as Microsoft's WebFolders).
@@ -127,9 +154,6 @@ static int fixup_dir(request_rec *r)
return DECLINED;
}
d = (dir_config_rec *)ap_get_module_config(r->per_dir_config,
&dir_module);
if (d->index_names) {
names_ptr = (char **)d->index_names->elts;
num_names = d->index_names->nelts;