We really need to fix this issue of inappropriate DefaultTypes.
An approach that deals with this without loss of back-compatibility
is to hand the decision to systems administrators:
#to suppress setting content-type when the server has no information
DefaultType !
Any thoughts on this and the attached patch?
--
Nick Kew
Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/
Index: include/httpd.h
===================================================================
--- include/httpd.h (revision 579662)
+++ include/httpd.h (working copy)
@@ -233,6 +233,14 @@
#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 "!"
+#endif
+
/** The name of the MIME types file */
#ifndef AP_TYPES_CONFIG_FILE
#define AP_TYPES_CONFIG_FILE "conf/mime.types"
Index: modules/http/byterange_filter.c
===================================================================
--- modules/http/byterange_filter.c (revision 579662)
+++ modules/http/byterange_filter.c (working copy)
@@ -193,12 +193,21 @@
"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));
}
Index: modules/http/http_filters.c
===================================================================
--- modules/http/http_filters.c (revision 579662)
+++ modules/http/http_filters.c (working copy)
@@ -952,6 +952,7 @@
apr_bucket_brigade *b2;
header_struct h;
header_filter_ctx *ctx = f->ctx;
+ const char *ctype;
AP_DEBUG_ASSERT(!r->main);
@@ -1027,8 +1028,10 @@
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",