]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r579991, r580502, r584842 from trunk:
authorJim Jagielski <jim@apache.org>
Mon, 29 Oct 2007 13:11:42 +0000 (13:11 +0000)
committerJim Jagielski <jim@apache.org>
Mon, 29 Oct 2007 13:11:42 +0000 (13:11 +0000)
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

CHANGES
STATUS
docs/manual/mod/core.xml
include/httpd.h
modules/http/byterange_filter.c
modules/http/http_filters.c

diff --git a/CHANGES b/CHANGES
index ed78ed5ebbcfde018b9ae54ed887da53fae26a3a..a67046951a599f1ad7b741ce8844e73168b2a962 100644 (file)
--- 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 <guenther.gsenger gmail.com>]
 
diff --git a/STATUS b/STATUS
index e77f4b88aad3d1d883e1b73173188bd00bb69317..bf22e445ecec402826d9f309320db50b3642cb60 100644 (file)
--- 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
index e2b2b0a2d561ca825c46040f392a5ce722d828d1..4aa72836a19e11b6d2195d2c0378271a0f830202 100644 (file)
@@ -596,7 +596,7 @@ headers</description>
 <name>DefaultType</name>
 <description>MIME content-type that will be sent if the
 server cannot determine a type in any other way</description>
-<syntax>DefaultType <var>MIME-type</var></syntax>
+<syntax>DefaultType <var>MIME-type|none</var></syntax>
 <default>DefaultType text/plain</default>
 <contextlist><context>server config</context><context>virtual host</context>
 <context>directory</context><context>.htaccess</context>
@@ -608,8 +608,9 @@ server cannot determine a type in any other way</description>
     document whose type cannot be determined by its <glossary
     ref="mime-type">MIME types</glossary> mappings.</p>
 
-    <p>The server must inform the client of the content-type of the
-    document, so in the event of an unknown type it uses the
+    <p>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
     <code>DefaultType</code>. For example:</p>
 
     <example>
@@ -619,6 +620,15 @@ server cannot determine a type in any other way</description>
     <p>would be appropriate for a directory which contained many GIF
     images with filenames missing the <code>.gif</code> extension.</p>
 
+    <p>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</p>
+    <example>
+      DefaultType None
+    </example>
+    <p>DefaultType None is only available in httpd-2.2.7 and later.</p>
+
     <p>Note that unlike <directive
     module="core">ForceType</directive>, this directive only
     provides the default mime-type. All other mime-type definitions,
index d4f61c4f99aabf8ebd093b54b6292d3d7e0870f7..8c784ee5109f8be61a244c5eeb0f73a7802c43a3 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 8d36e9215fc36597a1c2867ddf3ae4e943956da4..6fabf96e4cfb66f2eb03772dcae204342b2c4839 100644 (file)
@@ -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",