You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2019/03/16 18:15:23 UTC

svn commit: r1855663 - in /httpd/httpd/trunk: CHANGES docs/manual/mod/mod_mime.xml modules/http/mod_mime.c

Author: covener
Date: Sat Mar 16 18:15:23 2019
New Revision: 1855663

URL: http://svn.apache.org/viewvc?rev=1855663&view=rev
Log:
allow mod_mime to be de disabled per-dir too

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/docs/manual/mod/mod_mime.xml
    httpd/httpd/trunk/modules/http/mod_mime.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1855663&r1=1855662&r2=1855663&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sat Mar 16 18:15:23 2019
@@ -6,7 +6,8 @@ Changes with Apache 2.5.1
      configurations in <Location> or <Proxy> 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]

Modified: httpd/httpd/trunk/docs/manual/mod/mod_mime.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_mime.xml?rev=1855663&r1=1855662&r2=1855663&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_mime.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_mime.xml Sat Mar 16 18:15:23 2019
@@ -1082,6 +1082,11 @@ RemoveType .cgi
       <dd>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.) .</dd>
+      <dt><code>Disable</code></dt>
+      <dd>All assignment of metadata based on the filename is skipped.</dd>
+      <dt><code>Enable</code></dt>
+      <dd>Re-enables assignment of metadata based on the filename. Only useful if a lower
+      precedence section has specified <code>MimeOptions Disable</code>.</dd>
     </dl>
 </usage>
 </directivesynopsis>

Modified: httpd/httpd/trunk/modules/http/mod_mime.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/mod_mime.c?rev=1855663&r1=1855662&r2=1855663&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http/mod_mime.c (original)
+++ httpd/httpd/trunk/modules/http/mod_mime.c Sat Mar 16 18:15:23 2019
@@ -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_
     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_
     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. */