From: William A. Rowe Jr Date: Mon, 25 Nov 2002 19:02:44 +0000 (+0000) Subject: Set the appropriate mime response headers for negotated type-map X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe8d30929d6ec20a56bbd86ecd83a4299bc71afa;p=apache Set the appropriate mime response headers for negotated type-map 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 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@97648 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/mappers/mod_negotiation.c b/modules/mappers/mod_negotiation.c index 28e7aa5598..41ef479999 100644 --- a/modules/mappers/mod_negotiation.c +++ b/modules/mappers/mod_negotiation.c @@ -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; }