--- mod_ua_charset.c 2000/04/18 06:56:17 1.3 +++ mod_ua_charset.c 2000/04/18 07:36:39 1.4 @@ -57,7 +57,12 @@ /* charset module * - + * sets `Contnet-type: text/html; charset=foobar' based on user agent string + * from client browser + * + * Dobrica Pavlinusic + * Robert Avilov + * */ @@ -72,25 +77,28 @@ const char *ua, *ct; ua = ap_table_get(r->headers_in, "User-Agent"); - /*ct = ap_table_get(r->headers_in, "Content-Type"); */ - /**** Isn't this better? */ - ct = r->content_type; - if (ua != NULL) - ap_table_setn(r->headers_out, "X-User-Agent", ua); - else + if (ua == NULL) ua = ""; -#if 1 - if (ct != NULL) - ap_table_setn(r->headers_out, "X-Content-Type", ct); - if (strstr(ct, "text/html") == NULL) - return DECLINED; /* Don't mess with other types */ - if (strstr(ua, "Mac") != NULL) { - if (strstr(ua, "MSIE") != NULL) - r->content_type = "text/html; charset=x-mac-roman"; - else - r->content_type = "text/html; charset=MacCE"; - } else - r->content_type = "text/html; charset=iso-8859-2"; + + ct = r->content_type; + + if (ct != NULL) { + + if (strstr(ct, "text/html") == NULL) + return DECLINED; /* Don't mess with other types */ + + if (strstr(ua, "Mac") != NULL) { + if (strstr(ua, "MSIE") != NULL) + r->content_type = "text/html; charset=x-mac-roman"; + else + r->content_type = "text/html; charset=MacCE"; + } else + r->content_type = "text/html; charset=iso-8859-2"; + } + +#ifdef DEBUG + ap_table_setn(r->headers_out, "X-Content-Type", ct); + ap_table_setn(r->headers_out, "X-User-Agent", ua); #endif return OK; }