From a5e74932addacbbdf34ca96b941c5c71c2b97c00 Mon Sep 17 00:00:00 2001 From: Nick Kew Date: Thu, 27 Sep 2007 12:43:42 +0000 Subject: [PATCH] Add "DefaultType None" option PR 13986 and PR 16139 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@579991 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ include/httpd.h | 8 ++++++++ modules/http/byterange_filter.c | 21 +++++++++++++++------ modules/http/http_filters.c | 7 +++++-- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 54498693d7..fdf38f8fb6 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.3.0 [ When backported to 2.2.x, remove entry from this file ] + *) HTTP protocol: Add "DefaultType none" option. + PR 13986 and PR 16139 [Nick Kew] + *) mod_proxy_ajp: Ignore any ajp13 flush packets received before we send the response headers. See Tomcat PR 43478. [Jim Jagielski] diff --git a/include/httpd.h b/include/httpd.h index 5573e1f0db..454e8b0681 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 073e27e0bf..a25d1e5957 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 35c6c429ac..bf17d8fedd 100644 --- a/modules/http/http_filters.c +++ b/modules/http/http_filters.c @@ -952,6 +952,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); @@ -1027,8 +1028,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", -- 2.40.0