]> granicus.if.org Git - apache/commitdiff
make trailing-slash-behaviour configurable
authorAndré Malo <nd@apache.org>
Sat, 3 Jul 2004 16:43:39 +0000 (16:43 +0000)
committerAndré Malo <nd@apache.org>
Sat, 3 Jul 2004 16:43:39 +0000 (16:43 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@104154 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/mappers/mod_dir.c

diff --git a/CHANGES b/CHANGES
index 9226be9ee29a992459937a09afa206b614fb307c..5e427e56956728e6e5b0a637cfb87f5738ae32ea 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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é 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>]
index 8bd5b9e60b64cb984b0b51fe6e7ae01c8d3fa498..c6e7f0d506417cdcfd9a43ac57e8b1fef7d7e512 100644 (file)
 
 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;