]> granicus.if.org Git - apache/commitdiff
Set the appropriate mime response headers for negotated type-map
authorWilliam A. Rowe Jr <wrowe@apache.org>
Mon, 25 Nov 2002 19:02:44 +0000 (19:02 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Mon, 25 Nov 2002 19:02:44 +0000 (19:02 +0000)
  Body: responses.

  wrowe's review;
    My earlier concern doesn't apply.  Type maps have always required the
    author to be explicit in all header fields to be negotiated; if the
    headers aren't given in the type map file the resulting redirect
    (for non-body maps) is broken anyways.  As to my other concern, the
    charset should only exist if the Content-Type was given.

Submitted by: Andr� Malo <nd@perlig.de>

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

modules/mappers/mod_negotiation.c

index 28e7aa5598e037da2a34bcf16cbb1df64615ab92..41ef4799999f916a0af26a7a4f55d7e47015f808 100644 (file)
@@ -2844,7 +2844,34 @@ static int handle_map_file(request_rec *r)
          * ap_set_etag(r);
          */
         apr_table_setn(r->headers_out, "Accept-Ranges", "bytes");
-        ap_set_content_length(r, best->bytes); 
+        ap_set_content_length(r, best->bytes);
+
+        /* set MIME type and charset as negotiated */
+        if (best->mime_type && *best->mime_type) {
+            if (best->content_charset && *best->content_charset) {
+                ap_set_content_type(r, apr_pstrcat(r->pool,
+                                                   best->mime_type,
+                                                   "; charset=",
+                                                   best->content_charset,
+                                                   NULL));
+            }
+            else {
+                ap_set_content_type(r, apr_pstrdup(r->pool, best->mime_type));
+            }
+        }
+
+        /* set Content-language(s) as negotiated */
+        if (best->content_languages && best->content_languages->nelts) {
+            r->content_languages = apr_array_copy(r->pool,
+                                                  best->content_languages);
+        }
+
+        /* set Content-Encoding as negotiated */
+        if (best->content_encoding && *best->content_encoding) {
+            r->content_encoding = apr_pstrdup(r->pool,
+                                              best->content_encoding);
+        }
+
         if ((res = ap_meets_conditions(r)) != OK) {
             return res;
         }