]> granicus.if.org Git - apache/commitdiff
Add ModMimeUsePathInfo directive.
authorJustin Erenkrantz <jerenkrantz@apache.org>
Thu, 5 Sep 2002 07:31:14 +0000 (07:31 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Thu, 5 Sep 2002 07:31:14 +0000 (07:31 +0000)
This directive allows mod_mime to lookup extension information for content
served via Location blocks so that content-type, filters, etc can be
applied to non-file content.

(I wouldn't be shocked if we end up changing the directive name.)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96644 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/http/mod_mime.c

diff --git a/CHANGES b/CHANGES
index 6fae7228e65932acd6cc9272e68abb6dfe6baf59..8398241ab6aaab80c1ea00d17698935c17769745 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,7 @@
 Changes with Apache 2.0.41
 
+  *) Add ModMimeUsePathInfo directive.  [Justin Erenkrantz]
+
   *) mod_cache: added support for caching streamed responses (proxy,
      CGI, etc) with optional CacheMaxStreamingBuffer setting [Brian Pane]
 
index c777917bb049daf8975ca5c8ae131ba3928c05bf..7899049f92abd5321e0fe42be463b9d6534cb842 100644 (file)
@@ -127,6 +127,12 @@ typedef struct {
     int multimatch;       /* Extensions to include in multiview matching
                            * for filenames, e.g. Filters and Handlers 
                            */
+    int use_path_info;    /* If set to 0, only use filename.
+                           * If set to 1, append PATH_INFO to filename for
+                           *   lookups.
+                           * If set to 2, this value is unset and is
+                           *   effectively 0.  
+                           */
 } mime_dir_config;
 
 typedef struct param_s {
@@ -162,6 +168,8 @@ static void *create_mime_dir_config(apr_pool_t *p, char *dummy)
 
     new->multimatch = MULTIMATCH_UNSET;
 
+    new->use_path_info = 2;
+
     return new;
 }
 /*
@@ -267,6 +275,13 @@ static void *merge_mime_dir_configs(apr_pool_t *p, void *basev, void *addv)
     new->multimatch = (add->multimatch != MULTIMATCH_UNSET) ?
         add->multimatch : base->multimatch;
 
+    if ((add->use_path_info & 2) == 0) {
+        new->use_path_info = add->use_path_info;
+    }
+    else {
+        new->use_path_info = base->use_path_info;
+    }
+
     return new;
 }
 
@@ -430,6 +445,9 @@ static const command_rec mime_cmds[] =
         "one or more file extensions"),
     AP_INIT_TAKE1("TypesConfig", set_types_config, NULL, RSRC_CONF,
         "the MIME types config file"),
+    AP_INIT_FLAG("ModMimeUsePathInfo", ap_set_flag_slot,
+        (void *)APR_OFFSETOF(mime_dir_config, use_path_info), ACCESS_CONF,
+        "Set to 'yes' to allow mod_mime to use path info for type checking"),
     {NULL}
 };
 
@@ -764,7 +782,7 @@ static int find_ct(request_rec *r)
     mime_dir_config *conf;
     apr_array_header_t *exception_list;
     char *ext;
-    const char *fn, *type, *charset = NULL;
+    const char *fn, *type, *charset = NULL, *resource_name;
     int found_metadata = 0;
 
     if (r->finfo.filetype == APR_DIR) {
@@ -776,10 +794,18 @@ static int find_ct(request_rec *r)
                                                    &mime_module);
     exception_list = apr_array_make(r->pool, 2, sizeof(char *));
 
+    /* If use_path_info is explicitly set to on (value & 1 == 1), append. */
+    if (conf->use_path_info & 1) {
+        resource_name = apr_pstrcat(r->pool, r->filename, r->path_info, NULL);
+    }
+    else {
+        resource_name = r->filename;
+    }
+
     /* Always drop the path leading up to the file name.
      */
-    if ((fn = strrchr(r->filename, '/')) == NULL) {
-        fn = r->filename;
+    if ((fn = strrchr(resource_name, '/')) == NULL) {
+        fn = resource_name;
     }
     else {
         ++fn;