From: Jim Jagielski
Date: Mon, 29 Oct 2007 13:11:42 +0000 (+0000)
Subject: Merge r579991, r580502, r584842 from trunk:
X-Git-Tag: 2.2.7~277
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1013685e840220dbef9db5b35f9d113512c8259;p=thirdparty%2Fapache%2Fhttpd.git
Merge r579991, r580502, r584842 from trunk:
Add "DefaultType None" option
PR 13986 and PR 16139
Document "DefaultType None" option (PR 13986)
Improve documentation of "DefaultType None"
Submitted by: niq
Reviewed by: jim
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@589616 13f79535-47bb-0310-9956-ffa450edef68
---
diff --git a/CHANGES b/CHANGES
index ed78ed5ebbc..a67046951a5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
-*- coding: utf-8 -*-
Changes with Apache 2.2.7
+ *) HTTP protocol: Add "DefaultType none" option.
+ PR 13986 and PR 16139 [Nick Kew]
+
*) mod_rewrite: Add option to suppress URL unescaping
PR 34602 [Guenther Gsenger ]
diff --git a/STATUS b/STATUS
index e77f4b88aad..bf22e445ece 100644
--- a/STATUS
+++ b/STATUS
@@ -79,13 +79,6 @@ RELEASE SHOWSTOPPERS:
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- * HTTP protocol: Add "DefaultType none" option.
- PR 13986 and PR 16139
- http://svn.apache.org/viewvc?view=rev&revision=579991 (code)
- http://svn.apache.org/viewvc?view=rev&revision=580502 (docs)
- http://svn.apache.org/viewvc?view=rev&revision=584842 (docs)
- +1: niq, rpluem, jim
-
* Core: Fix possible crash at startup in case of nonexistent DocumentRoot.
PR 39722
http://svn.apache.org/viewvc?view=rev&revision=589177
diff --git a/docs/manual/mod/core.xml b/docs/manual/mod/core.xml
index e2b2b0a2d56..4aa72836a19 100644
--- a/docs/manual/mod/core.xml
+++ b/docs/manual/mod/core.xml
@@ -596,7 +596,7 @@ headers
DefaultType
MIME content-type that will be sent if the
server cannot determine a type in any other way
-DefaultType MIME-type
+DefaultType MIME-type|none
DefaultType text/plain
server configvirtual host
directory.htaccess
@@ -608,8 +608,9 @@ server cannot determine a type in any other way
document whose type cannot be determined by its MIME types mappings.
- The server must inform the client of the content-type of the
- document, so in the event of an unknown type it uses the
+
The server SHOULD inform the client of the content-type of the
+ document. If the server is unable to determine this by normal
+ means, it will set it to the configured
DefaultType
. For example:
@@ -619,6 +620,15 @@ server cannot determine a type in any other way
would be appropriate for a directory which contained many GIF
images with filenames missing the .gif
extension.
+ In cases where it can neither be determined by the server nor
+ the administrator (e.g. a proxy), it is preferable to omit the MIME
+ type altogether rather than provide information that may be false.
+ This can be accomplished using
+
+ DefaultType None
+
+ DefaultType None is only available in httpd-2.2.7 and later.
+
Note that unlike ForceType, this directive only
provides the default mime-type. All other mime-type definitions,
diff --git a/include/httpd.h b/include/httpd.h
index d4f61c4f99a..8c784ee5109 100644
--- a/include/httpd.h
+++ b/include/httpd.h
@@ -233,6 +233,14 @@ extern "C" {
#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"
diff --git a/modules/http/byterange_filter.c b/modules/http/byterange_filter.c
index 073e27e0bfd..a25d1e5957d 100644
--- a/modules/http/byterange_filter.c
+++ b/modules/http/byterange_filter.c
@@ -193,12 +193,21 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f,
"byteranges; boundary=",
ctx->boundary, NULL));
- ctx->bound_head = apr_pstrcat(r->pool,
- CRLF "--", ctx->boundary,
- CRLF "Content-type: ",
- orig_ct,
- CRLF "Content-range: bytes ",
- NULL);
+ if (strcasecmp(orig_ct, NO_CONTENT_TYPE)) {
+ ctx->bound_head = apr_pstrcat(r->pool,
+ CRLF "--", ctx->boundary,
+ CRLF "Content-type: ",
+ orig_ct,
+ CRLF "Content-range: bytes ",
+ NULL);
+ }
+ else {
+ /* if we have no type for the content, do our best */
+ ctx->bound_head = apr_pstrcat(r->pool,
+ CRLF "--", ctx->boundary,
+ CRLF "Content-range: bytes ",
+ NULL);
+ }
ap_xlate_proto_to_ascii(ctx->bound_head, strlen(ctx->bound_head));
}
diff --git a/modules/http/http_filters.c b/modules/http/http_filters.c
index 8d36e9215fc..6fabf96e4cf 100644
--- a/modules/http/http_filters.c
+++ b/modules/http/http_filters.c
@@ -926,6 +926,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f,
apr_bucket_brigade *b2;
header_struct h;
header_filter_ctx *ctx = f->ctx;
+ const char *ctype;
AP_DEBUG_ASSERT(!r->main);
@@ -1001,8 +1002,10 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f,
apr_table_unset(r->headers_out, "Content-Length");
}
- apr_table_setn(r->headers_out, "Content-Type",
- ap_make_content_type(r, r->content_type));
+ ctype = ap_make_content_type(r, r->content_type);
+ if (strcasecmp(ctype, NO_CONTENT_TYPE)) {
+ apr_table_setn(r->headers_out, "Content-Type", ctype);
+ }
if (r->content_encoding) {
apr_table_setn(r->headers_out, "Content-Encoding",