]> granicus.if.org Git - apache/commitdiff
Add "DefaultType None" option
authorNick Kew <niq@apache.org>
Thu, 27 Sep 2007 12:43:42 +0000 (12:43 +0000)
committerNick Kew <niq@apache.org>
Thu, 27 Sep 2007 12:43:42 +0000 (12:43 +0000)
PR 13986 and PR 16139

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@579991 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
include/httpd.h
modules/http/byterange_filter.c
modules/http/http_filters.c

diff --git a/CHANGES b/CHANGES
index 54498693d72d9f1a9714628bfb0b75048402491b..fdf38f8fb663a66741213efb8416dcc19ad93b0f 100644 (file)
--- 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]
index 5573e1f0dbc7872ce8869ad2d5f239792bb84828..454e8b0681ece8cb46cbbf468379b2452780ec51 100644 (file)
@@ -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"
index 073e27e0bfdb90a8e126dd3f47be421f689268e1..a25d1e5957d8a96c2fc4c2c4e0ecc8d4d1ef40b0 100644 (file)
@@ -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));
     }
 
index 35c6c429ac2eb68278693c19c2fbd3d4eeb257b4..bf17d8fedd74303c60a2f691f6ec704253fa7fc1 100644 (file)
@@ -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",