57 |
|
|
58 |
/* charset module |
/* charset module |
59 |
* |
* |
60 |
|
* sets `Contnet-type: text/html; charset=foobar' based on user agent string |
61 |
|
* from client browser |
62 |
|
* |
63 |
|
* Dobrica Pavlinusic <dpavlin@rot13.org> |
64 |
|
* Robert Avilov <ravilov@linux.hr> |
65 |
|
* |
66 |
*/ |
*/ |
67 |
|
|
68 |
|
|
77 |
const char *ua, *ct; |
const char *ua, *ct; |
78 |
|
|
79 |
ua = ap_table_get(r->headers_in, "User-Agent"); |
ua = ap_table_get(r->headers_in, "User-Agent"); |
80 |
/*ct = ap_table_get(r->headers_in, "Content-Type"); */ |
if (ua == NULL) |
|
/**** Isn't this better? */ |
|
|
ct = r->content_type; |
|
|
if (ua != NULL) |
|
|
ap_table_setn(r->headers_out, "X-User-Agent", ua); |
|
|
else |
|
81 |
ua = "<unknown>"; |
ua = "<unknown>"; |
82 |
#if 1 |
|
83 |
if (ct != NULL) |
ct = r->content_type; |
84 |
ap_table_setn(r->headers_out, "X-Content-Type", ct); |
|
85 |
if (strstr(ct, "text/html") == NULL) |
if (ct != NULL) { |
86 |
return DECLINED; /* Don't mess with other types */ |
|
87 |
if (strstr(ua, "Mac") != NULL) { |
if (strstr(ct, "text/html") == NULL) |
88 |
if (strstr(ua, "MSIE") != NULL) |
return DECLINED; /* Don't mess with other types */ |
89 |
r->content_type = "text/html; charset=x-mac-roman"; |
|
90 |
else |
if (strstr(ua, "Mac") != NULL) { |
91 |
r->content_type = "text/html; charset=MacCE"; |
if (strstr(ua, "MSIE") != NULL) |
92 |
} else |
r->content_type = "text/html; charset=x-mac-roman"; |
93 |
r->content_type = "text/html; charset=iso-8859-2"; |
else |
94 |
|
r->content_type = "text/html; charset=MacCE"; |
95 |
|
} else |
96 |
|
r->content_type = "text/html; charset=iso-8859-2"; |
97 |
|
} |
98 |
|
|
99 |
|
#ifdef DEBUG |
100 |
|
ap_table_setn(r->headers_out, "X-Content-Type", ct); |
101 |
|
ap_table_setn(r->headers_out, "X-new-Content-Type", r->content_type); |
102 |
|
ap_table_setn(r->headers_out, "X-User-Agent", ua); |
103 |
#endif |
#endif |
104 |
return OK; |
return DECLINED; |
105 |
} |
} |
106 |
|
|
107 |
module MODULE_VAR_EXPORT ua_charset_module = { |
module MODULE_VAR_EXPORT ua_charset_module = { |