You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by nd...@apache.org on 2004/07/03 18:43:39 UTC
cvs commit: httpd-2.0/modules/mappers mod_dir.c
nd 2004/07/03 09:43:39
Modified: . CHANGES
modules/mappers mod_dir.c
Log:
make trailing-slash-behaviour configurable
Revision Changes Path
1.1527 +3 -0 httpd-2.0/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/httpd-2.0/CHANGES,v
retrieving revision 1.1526
retrieving revision 1.1527
diff -u -u -r1.1526 -r1.1527
--- CHANGES 3 Jul 2004 12:51:24 -0000 1.1526
+++ CHANGES 3 Jul 2004 16:43:39 -0000 1.1527
@@ -2,6 +2,9 @@
[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� 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>]
1.48 +27 -3 httpd-2.0/modules/mappers/mod_dir.c
Index: mod_dir.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_dir.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -u -r1.47 -r1.48
--- mod_dir.c 9 Feb 2004 20:29:20 -0000 1.47
+++ mod_dir.c 3 Jul 2004 16:43:39 -0000 1.48
@@ -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 @@
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 @@
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 @@
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 @@
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).
@@ -126,9 +153,6 @@
if (strcmp(r->handler, DIR_MAGIC_TYPE)) {
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;