]> granicus.if.org Git - apache/commitdiff
Disabled DefaultType directive and removed ap_default_type()
authorRoy T. Fielding <fielding@apache.org>
Fri, 30 Jan 2009 19:12:51 +0000 (19:12 +0000)
committerRoy T. Fielding <fielding@apache.org>
Fri, 30 Jan 2009 19:12:51 +0000 (19:12 +0000)
from core.  We now exclude Content-Type from responses for which
a media type has not been configured via mime.types, AddType,
ForceType, or some other mechanism.  MMN major bump to NZ time.

PR: 13986

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

14 files changed:
CHANGES
include/ap_mmn.h
include/http_core.h
include/http_protocol.h
include/httpd.h
modules/filters/mod_charset_lite.c
modules/http/byterange_filter.c
modules/http/http_filters.c
modules/mappers/mod_actions.c
modules/mappers/mod_negotiation.c
modules/proxy/mod_proxy_ftp.c
server/config.c
server/core.c
server/protocol.c

diff --git a/CHANGES b/CHANGES
index f7e611b1297064c5f9ca6a67d1055ae460d1889e..6ab6921ef63bc90b1a685ffdaccbc6bb398e9f0f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,11 @@
 Changes with Apache 2.3.2
 [ When backported to 2.2.x, remove entry from this file ]
 
+ *) Disabled DefaultType directive and removed ap_default_type()
+    from core.  We now exclude Content-Type from responses for which
+    a media type has not been configured via mime.types, AddType,
+    ForceType, or some other mechanism. PR 13986. [Roy T. Fielding]
+
  *) mod_rewrite: Add IPV6 variable to RewriteCond
     [Ryan Phillips <ryan-apache trolocsis.com>]
 
index 27230a97d18bcb33b3a17d68781881540148789e..2005d199072e91c478e04571110ea04941ee0629 100644 (file)
  * 20081231.0 (2.3.0-dev)  Switch ap_escape_html API: add ap_escape_html2,
  *                         and make ap_escape_html a macro for it.
  * 20090130.0 (2.3.2-dev)  Add ap_ prefix to unixd_setup_child().
+ * 20090131.0 (2.3.2-dev)  Remove ap_default_type(), disable DefaultType
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20090130
+#define MODULE_MAGIC_NUMBER_MAJOR 20090131
 #endif
 #define MODULE_MAGIC_NUMBER_MINOR 0                     /* 0...n */
 
index e5b1ac0d6ad64b80c6fe869bccb7069412b5a261..1c34c783a42343c0ef4e2a73d8dfc00dd67fa20a 100644 (file)
@@ -148,13 +148,6 @@ AP_DECLARE(int) ap_allow_options(request_rec *r);
  */
 AP_DECLARE(int) ap_allow_overrides(request_rec *r);
 
-/**
- * Retrieve the value of the DefaultType directive, or text/plain if not set
- * @param r The current request
- * @return The default type
- */
-AP_DECLARE(const char *) ap_default_type(request_rec *r);     
-
 /**
  * Retrieve the document root for this server
  * @param r The current request
@@ -438,13 +431,6 @@ typedef struct {
     overrides_t override;
     allow_options_t override_opts;
     
-    /* MIME typing --- the core doesn't do anything at all with this,
-     * but it does know what to slap on a request for a document which
-     * goes untyped by other mechanisms before it slips out the door...
-     */
-    
-    char *ap_default_type;
-  
     /* Custom response config. These can contain text or a URL to redirect to.
      * if response_code_strings is NULL then there are none in the config,
      * if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES.
index e93901e1f23c5eb0a0ecf960e92fc8c8adcd5731..bf405af4e58450e57ceb43113e11ea39e418373c 100644 (file)
@@ -129,7 +129,7 @@ AP_DECLARE(apr_time_t) ap_rationalize_mtime(request_rec *r, apr_time_t mtime);
 /**
  * Build the content-type that should be sent to the client from the
  * content-type specified.  The following rules are followed:
- *    - if type is NULL, type is set to ap_default_type(r)
+ *    - if type is NULL or "", return NULL (do not set content-type).
  *    - if charset adding is disabled, stop processing and return type.
  *    - then, if there are no parameters on type, add the default charset
  *    - return type
index c2d4fcc5135634339bc517ed01a64c2b5043ce7e..c5f8c8448dbc7f527215dd855086f5e1c8be0912 100644 (file)
@@ -219,24 +219,6 @@ extern "C" {
 #define AP_DEFAULT_INDEX "index.html"
 #endif
 
-
-/** 
- * Define this to be what type you'd like returned for files with unknown 
- * suffixes.  
- * @warning MUST be all lower case. 
- */
-#ifndef DEFAULT_CONTENT_TYPE
-#define DEFAULT_CONTENT_TYPE "text/plain"
-#endif
-
-/**
- * NO_CONTENT_TYPE is an alternative DefaultType value that suppresses
- * setting any default type when there's no information (e.g. a proxy).
- */
-#ifndef NO_CONTENT_TYPE
-#define NO_CONTENT_TYPE "none"
-#endif
-
 /** The name of the MIME types file */
 #ifndef AP_TYPES_CONFIG_FILE
 #define AP_TYPES_CONFIG_FILE "conf/mime.types"
index 71045490d22f6359b13d58ae44703a4f797a621b..b5c462ec83c7b196bc75f6eb8b6ef7dc7476ce5f 100644 (file)
@@ -803,9 +803,9 @@ static apr_status_t xlate_out_filter(ap_filter_t *f, apr_bucket_brigade *bb)
     /* Check the mime type to see if translation should be performed.
      */
     if (!ctx->noop && ctx->xlate == NULL) {
-        const char *mime_type = f->r->content_type ? f->r->content_type : ap_default_type(f->r);
+        const char *mime_type = f->r->content_type;
 
-        if (strncasecmp(mime_type, "text/", 5) == 0 ||
+        if (mime_type && (strncasecmp(mime_type, "text/", 5) == 0 ||
 #if APR_CHARSET_EBCDIC
         /* On an EBCDIC machine, be willing to translate mod_autoindex-
          * generated output.  Otherwise, it doesn't look too cool.
@@ -822,7 +822,7 @@ static apr_status_t xlate_out_filter(ap_filter_t *f, apr_bucket_brigade *bb)
             strcmp(mime_type, DIR_MAGIC_TYPE) == 0 ||
 #endif
             strncasecmp(mime_type, "message/", 8) == 0 || 
-            dc->force_xlate == FX_FORCE) {
+            dc->force_xlate == FX_FORCE)) {
 
             rv = apr_xlate_open(&ctx->xlate,
                                 dc->charset_default, dc->charset_source, f->r->pool);
@@ -840,7 +840,7 @@ static apr_status_t xlate_out_filter(ap_filter_t *f, apr_bucket_brigade *bb)
         }
         else {
             ctx->noop = 1;
-            if (dc->debug >= DBGLVL_GORY) {
+            if (mime_type && dc->debug >= DBGLVL_GORY) {
                 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r,
                               "mime type is %s; no translation selected",
                               mime_type);
index 6e172a652af65b28c514615d0f05c27da90ec10e..a79b7f7d6deb88cff6bca019bfb0a6a3053fa4f4 100644 (file)
@@ -192,7 +192,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f,
                                            "byteranges; boundary=",
                                            ctx->boundary, NULL));
 
-        if (strcasecmp(orig_ct, NO_CONTENT_TYPE)) {
+        if (orig_ct) {
             ctx->bound_head = apr_pstrcat(r->pool,
                                           CRLF "--", ctx->boundary,
                                           CRLF "Content-type: ",
index b42b47fb69a629bf4985a036daad0132bea34fcb..4af27a6a3f5faefb46edb37cd9da0f6f1cd9e91f 100644 (file)
@@ -1181,7 +1181,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f,
     }
 
     ctype = ap_make_content_type(r, r->content_type);
-    if (strcasecmp(ctype, NO_CONTENT_TYPE)) {
+    if (ctype) {
         apr_table_setn(r->headers_out, "Content-Type", ctype);
     }
 
index ac983aa508bece1c6f3f1918429461167451c52a..7b072bebfb55e8c2758d2a2a31e7460553611c9d 100644 (file)
@@ -178,9 +178,8 @@ static int action_handler(request_rec *r)
     /* Second, check for actions (which override the method scripts) */
     action = r->handler ? r->handler :
         ap_field_noparam(r->pool, r->content_type);
-    action = action ? action : ap_default_type(r);
 
-    if ((t = apr_table_get(conf->action_types, action))) {
+    if (action && (t = apr_table_get(conf->action_types, action))) {
         if (*t++ == '0' && r->finfo.filetype == 0) {
             ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                           "File does not exist: %s", r->filename);
index f095b943bd0b88ca60319f89e54c31f6b0a262b7..923cc050293541c47c35be8a454c70620fe4cf20 100644 (file)
@@ -1157,8 +1157,7 @@ static int read_types_multi(negotiation_state *neg)
         anymatch = 1;
 
         /* See if it's something which we have access to, and which
-         * has a known type and encoding (as opposed to something
-         * which we'll be slapping default_type on later).
+         * has a known type and encoding.
          */
         sub_req = ap_sub_req_lookup_dirent(&dirent, r, AP_SUBREQ_MERGE_ARGS,
                                            NULL);
@@ -1238,8 +1237,7 @@ static int read_types_multi(negotiation_state *neg)
         }
 
         /*
-         * ###: be warned, the _default_ content type is already
-         * picked up here!  If we failed the subrequest, or don't
+         * If we failed the subrequest, or don't
          * know what we are serving, then continue.
          */
         if (sub_req->status != HTTP_OK || (!sub_req->content_type)) {
index 1058bfe25caba14a1723c77d1c9b6fcbb4aeb095..028d766db2d6a70243469dda1bc34780d18cda6c 100644 (file)
@@ -1718,13 +1718,6 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
                                            "ISO-8859-1",  NULL));
     }
     else {
-        if (r->content_type) {
-            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
-                     "proxy: FTP: Content-Type set to %s", r->content_type);
-        }
-        else {
-            ap_set_content_type(r, ap_default_type(r));
-        }
         if (xfer_type != 'A' && size != NULL) {
             /* We "trust" the ftp server to really serve (size) bytes... */
             apr_table_setn(r->headers_out, "Content-Length", size);
@@ -1732,9 +1725,11 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
                          "proxy: FTP: Content-Length set to %s", size);
         }
     }
-    apr_table_setn(r->headers_out, "Content-Type", r->content_type);
-    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
-                 "proxy: FTP: Content-Type set to %s", r->content_type);
+    if (r->content_type) {
+        apr_table_setn(r->headers_out, "Content-Type", r->content_type);
+        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                     "proxy: FTP: Content-Type set to %s", r->content_type);
+    }
 
 #if defined(USE_MDTM) && (defined(HAVE_TIMEGM) || defined(HAVE_GMTOFF))
     if (mtime != 0L) {
index ddf31734f6dcb560ff88c3af6dc7561e6f6bbbfc..189cea522580529fd22f81ffdd3ec9d7a6dcf2f4 100644 (file)
@@ -355,15 +355,15 @@ AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r)
         return result;
     }
 
-    if (!r->handler) {
-        handler = r->content_type ? r->content_type : ap_default_type(r);
+    if (!r->handler && r->content_type) {
+        handler = r->content_type;
         if ((p=ap_strchr_c(handler, ';')) != NULL) {
             char *new_handler = (char *)apr_pmemdup(r->pool, handler,
                                                     p - handler + 1);
             char *p2 = new_handler + (p - handler);
             handler = new_handler;
 
-            /* MIME type arguments */
+            /* exclude media type arguments */
             while (p2 > handler && p2[-1] == ' ')
                 --p2; /* strip trailing spaces */
 
index 0dadf1a5d7e3c6c99a5bd9995070d3c87c7855b2..257b516a704ee88227d7f02032b1d067679cc468 100644 (file)
@@ -82,10 +82,8 @@ AP_IMPLEMENT_HOOK_RUN_ALL(int, get_mgmt_items,
  * server operations, including options and commands which control the
  * operation of other modules.  Consider this the bureaucracy module.
  *
- * The core module also defines handlers, etc., do handle just enough
- * to allow a server with the core module ONLY to actually serve documents
- * (though it slaps DefaultType on all of 'em); this was useful in testing,
- * but may not be worth preserving.
+ * The core module also defines handlers, etc., to handle just enough
+ * to allow a server with the core module ONLY to actually serve documents.
  *
  * This file could almost be mod_core.c, except for the stuff which affects
  * the http_conf_globals.
@@ -263,10 +261,6 @@ static void *merge_core_dir_configs(apr_pool_t *a, void *basev, void *newv)
         conf->override_opts = new->override_opts;
     }
 
-    if (new->ap_default_type) {
-        conf->ap_default_type = new->ap_default_type;
-    }
-
     if (conf->response_code_strings == NULL) {
         conf->response_code_strings = new->response_code_strings;
     }
@@ -702,18 +696,6 @@ AP_DECLARE(int) ap_satisfies(request_rec *r)
     return SATISFY_NOSPEC;
 }
 
-AP_DECLARE(const char *) ap_default_type(request_rec *r)
-{
-    core_dir_config *conf;
-
-    conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
-                                                   &core_module);
-
-    return conf->ap_default_type
-               ? conf->ap_default_type
-               : DEFAULT_CONTENT_TYPE;
-}
-
 AP_DECLARE(const char *) ap_document_root(request_rec *r) /* Don't use this! */
 {
     core_server_config *conf;
@@ -1477,6 +1459,18 @@ static const char *set_options(cmd_parms *cmd, void *d_, const char *l)
     return NULL;
 }
 
+static const char *set_default_type(cmd_parms *cmd, void *d_,
+                                   const char *arg)
+{
+    if ((strcasecmp(arg, "off") != 0) && (strcasecmp(arg, "none") != 0)) {
+        ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
+              "Ignoring deprecated use of DefaultType in line %d of %s.",
+                     cmd->directive->line_num, cmd->directive->filename);
+    }
+
+    return NULL;
+}
+
 /*
  * Note what data should be used when forming file ETag values.
  * It would be nicer to do this as an ITERATE, but then we couldn't
@@ -3246,9 +3240,8 @@ AP_INIT_RAW_ARGS("AllowOverride", set_override, NULL, ACCESS_CONF,
   "config files"),
 AP_INIT_RAW_ARGS("Options", set_options, NULL, OR_OPTIONS,
   "Set a number of attributes for a given directory"),
-AP_INIT_TAKE1("DefaultType", ap_set_string_slot,
-  (void*)APR_OFFSETOF(core_dir_config, ap_default_type),
-  OR_FILEINFO, "the default MIME type for untypable files"),
+AP_INIT_TAKE1("DefaultType", set_default_type, NULL, OR_FILEINFO,
+  "the default media type for otherwise untyped files (DEPRECATED)"),
 AP_INIT_RAW_ARGS("FileETag", set_etag_bits, NULL, OR_FILEINFO,
   "Specify components used to construct a file's ETag"),
 AP_INIT_TAKE1("EnableMMAP", set_enable_mmap, NULL, OR_FILEINFO,
index 0098111aca5c49c0287eefe67d1c52f0bdc69ed5..15d5f4e88235999d52b1ec832f5359a8e9490a84 100644 (file)
@@ -94,7 +94,7 @@ AP_DECLARE(void) ap_setup_make_content_type(apr_pool_t *pool)
 /*
  * Builds the content-type that should be sent to the client from the
  * content-type specified.  The following rules are followed:
- *    - if type is NULL, type is set to ap_default_type(r)
+ *    - if type is NULL or "", return NULL (do not set content-type).
  *    - if charset adding is disabled, stop processing and return type.
  *    - then, if there are no parameters on type, add the default charset
  *    - return type
@@ -108,8 +108,8 @@ AP_DECLARE(const char *)ap_make_content_type(request_rec *r, const char *type)
     core_request_config *request_conf;
     apr_size_t type_len;
 
-    if (!type) {
-        type = ap_default_type(r);
+    if (!type || *type == '\0') {
+        return NULL;
     }
 
     if (conf->add_default_charset != ADD_DEFAULT_CHARSET_ON) {