From 289304fe5832280ffa10dcb271b7d3e2b42c7ddc Mon Sep 17 00:00:00 2001 From: Justin Erenkrantz Date: Thu, 5 Sep 2002 07:31:14 +0000 Subject: [PATCH] Add ModMimeUsePathInfo directive. 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 | 2 ++ modules/http/mod_mime.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 6fae7228e6..8398241ab6 100644 --- 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] diff --git a/modules/http/mod_mime.c b/modules/http/mod_mime.c index c777917bb0..7899049f92 100644 --- a/modules/http/mod_mime.c +++ b/modules/http/mod_mime.c @@ -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; -- 2.50.1