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>]
* 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 */
*/
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
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.
/**
* 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
#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"
/* 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.
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);
}
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);
"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: ",
}
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);
}
/* 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);
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);
}
/*
- * ###: 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)) {
"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);
"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) {
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 */
* 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.
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;
}
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;
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
"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,
/*
* 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
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) {