Hi,
[sent a similiar patch several weeks ago, but wasn't noticed, so I try
it again.. :)]
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<---[ type.map ]-----------------------
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<---[ type.map ]-----------------------
The information will only be set if available, of course.
Technical Note: I'm not sure, whether copying the information there is
the right way (instead of assigning pointers), but I guess, you tell me,
if it's wrong ;-)
Since the distributed customized error documents are going to rely on
this header information, any feedback would be appreciated.
nd
--
$_=q?tvc!uif)%*|#Bopuifs!A`#~tvc!Xibu)%*|qsjou#Kvtu!A`#~tvc!KBQI!)*|~
tvc!ifmm)%*|#Qfsm!A`#~tvc!jt)%*|(Ibdlfs(~ # What the hell is JAPH? ;
@_=split/\s\s+#/;$_=(join''=>map{chr(ord( # Andr� Malo ;
$_)-1)}split//=>$_[0]).$_[1];s s.*s$_see; # 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 5 Oct 2002 16:34:40 -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;
}