[ Simply trying again; or according to Jeff: nag, nag, nag ;-) ]
If you use the "body" feature in type map files, the MIME-headers
currently are set dependant on what (mostly) type_checker says about the
type map file.
The attached patch sets the MIME-type, charset, content-language and
content-encoding of a negotiated type-map body. Thus you can hold
different types, languages etc. inside the same file, for example:
--------------8<---[ typemap.var ]-----------------------
Content-language: de
Content-type: text/html; charset=ISO-8859-1
Body:----------dehtml--
[german text/html document]
----------dehtml--
Content-language: de
Content-type: application/xhtml+xml; charset=UTF-8
Body:----------dexml--
[german application/xhtml+xml document; utf-8 encoded]
----------dexml--
Content-language: en
Content-type: text/plain; charset=us-ascii
Body:----------en--
[english text/plain document]
----------en--
--------------8<---[ typemap.var ]-----------------------
The information will only be set if available, of course.
nd
--
package Hacker::Perl::Another::Just;print
qq~@{[reverse split/::/ =>__PACKAGE__]}~;
# Andr� Malo # http://www.perlig.de #
Index: mod_negotiation.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/mappers/mod_negotiation.c,v
retrieving revision 1.107
diff -u -r1.107 mod_negotiation.c
--- mod_negotiation.c 9 Aug 2002 19:21:57 -0000 1.107
+++ mod_negotiation.c 26 Oct 2002 00:29:52 -0000
@@ -2841,6 +2841,33 @@
*/
apr_table_setn(r->headers_out, "Accept-Ranges", "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;
}