From df8df5b5a6fc5b9887eecdeb3b524b9123bec544 Mon Sep 17 00:00:00 2001 From: Eric Covener Date: Sat, 16 Mar 2019 18:15:23 +0000 Subject: [PATCH] allow mod_mime to be de disabled per-dir too git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1855663 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 ++- docs/manual/mod/mod_mime.xml | 5 +++++ modules/http/mod_mime.c | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index ad8f512d73..afcb891e19 100644 --- a/CHANGES +++ b/CHANGES @@ -6,7 +6,8 @@ Changes with Apache 2.5.1 configurations in or context. PR 63256. [Yann Ylavic] *) mod_mime: Add `MimeOptions` directive to allow Content-Type or all metadata - detection to use only the last (right-most) file extension. [Eric Covener] + detection to use only the last (right-most) file extension or to be + disabled per-dir. [Eric Covener] *) MPMs unix: bind the bucket number of each child to its slot number, for a more efficient per bucket maintenance. [Yann Ylavic] diff --git a/docs/manual/mod/mod_mime.xml b/docs/manual/mod/mod_mime.xml index 4e6314e27f..484f5c7d2b 100644 --- a/docs/manual/mod/mod_mime.xml +++ b/docs/manual/mod/mod_mime.xml @@ -1082,6 +1082,11 @@ RemoveType .cgi
This option can be used to revert to the default behavior of testing every filename extension when determining any response metadata (Content-Type, language, encoding, etc.) .
+
Disable
+
All assignment of metadata based on the filename is skipped.
+
Enable
+
Re-enables assignment of metadata based on the filename. Only useful if a lower + precedence section has specified MimeOptions Disable.
diff --git a/modules/http/mod_mime.c b/modules/http/mod_mime.c index 94672f228b..e951beedc1 100644 --- a/modules/http/mod_mime.c +++ b/modules/http/mod_mime.c @@ -95,6 +95,8 @@ typedef struct { enum {CT_LAST_INIT, CT_LAST_ON, CT_LAST_OFF} ct_last_ext; /* Only use the final extension for anything */ enum {ALL_LAST_INIT, ALL_LAST_ON, ALL_LAST_OFF} all_last_ext; + /* don't do any detection */ + enum {NOMIME_INIT, NOMIME_ON, NOMIME_OFF} nomime; } mime_dir_config; typedef struct param_s { @@ -251,6 +253,10 @@ static void *merge_mime_dir_configs(apr_pool_t *p, void *basev, void *addv) new->all_last_ext = (add->all_last_ext != ALL_LAST_INIT) ? add->all_last_ext : base->all_last_ext; + new->nomime = (add->nomime != NOMIME_INIT) + ? add->nomime + : base->nomime; + return new; } @@ -394,6 +400,12 @@ static const char *add_mime_options(cmd_parms *cmd, void *in_dc, else if (!strcasecmp(flag, "NoAllLastExtension")) { dc->all_last_ext = ALL_LAST_OFF; } + else if (!strcasecmp(flag, "Disable")) { + dc->nomime = NOMIME_ON; + } + else if (!strcasecmp(flag, "Enable")) { + dc->nomime = NOMIME_OFF; + } else { return apr_pstrcat(cmd->temp_pool, "Invalid MimeOptions option: ", @@ -814,6 +826,10 @@ static int find_ct(request_rec *r) conf = (mime_dir_config *)ap_get_module_config(r->per_dir_config, &mime_module); + if (conf->nomime == NOMIME_ON) { + return DECLINED; + } + exception_list = apr_array_make(r->pool, 2, sizeof(char *)); /* If use_path_info is explicitly set to on (value & 1 == 1), append. */ -- 2.50.1