mirror of
https://github.com/apache/httpd.git
synced 2025-11-05 05:30:39 +03:00
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. 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
This commit is contained in:
5
CHANGES
5
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>]
|
||||
|
||||
|
||||
@@ -187,12 +187,13 @@
|
||||
* 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 */
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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: ",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
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) {
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user