Anyone? I also attached a simple testcase for httpd-test.
You need to create perl-framework/t/htdocs/error_charset
directory.
BTW, where do I stand with regard to commit access to source
code area? I think theoretically its RTC like others but
practically I feel much more comfortable if someone can
review my patch.
Yoshiki Hayashi <[EMAIL PROTECTED]> writes:
> This problem was brought up in Japanese user list some time
> ago. In spite of the document, httpd 2.0 and 2.1 do not
> have special meaning for suppress-error-charset environment
> variable.
> http://httpd.apache.org/docs-2.1/env.html#special
>
> This feature was introduced to httpd 1.3 in revision 1.326
> of http_protocol.c with the following log message:
>
> | Add a new environment variable to keep the charset from being
> | included on canned error documents. (Having it there make
> | some browsers apply it to the redirect target document.)
> |
> | Reviewed by: Bill Stoddard, Jim Jagielski, Justin Erenkrantz, Cliff Woolley
>
> http://cvs.apache.org/viewcvs.cgi/apache-1.3/src/main/http_protocol.c
>
> When you test this patch, be sure to turn off
> AddDefaultCharset. It took me for a while to figure out who
> is adding the charset again.
>
Index: modules/http/http_protocol.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/http/http_protocol.c,v
retrieving revision 1.473
diff -u -r1.473 http_protocol.c
--- modules/http/http_protocol.c 16 Nov 2003 02:09:13 -0000 1.473
+++ modules/http/http_protocol.c 3 Dec 2003 19:16:44 -0000
@@ -2388,7 +2388,13 @@
r->content_languages = NULL;
r->content_encoding = NULL;
r->clength = 0;
- ap_set_content_type(r, "text/html; charset=iso-8859-1");
+ if (apr_table_get(r->subprocess_env,
+ "suppress-error-charset") != NULL) {
+ ap_set_content_type(r, "text/html");
+ }
+ else {
+ ap_set_content_type(r, "text/html; charset=iso-8859-1");
+ }
if ((status == HTTP_METHOD_NOT_ALLOWED)
|| (status == HTTP_NOT_IMPLEMENTED)) {
Index: perl-framework/t/apache/error_charset.t
===================================================================
RCS file: perl-framework/t/apache/error_charset.t
diff -N perl-framework/t/apache/error_charset.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ perl-framework/t/apache/error_charset.t 17 Dec 2003 23:11:32 -0000
@@ -0,0 +1,25 @@
+#
+# Test suppress-error-charset environmental variable
+#
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest;
+use Apache::TestUtil;
+
+t_debug "Checking the SuppressErrorCharset environmental variable\n";
+
+plan tests => 2;
+
+check_error_charset("a_bogus_name", "text/html; charset=iso-8859-1");
+check_error_charset("error_charset/a_bogus_name", "text/html");
+
+sub check_error_charset {
+ my ($path) = shift;
+ my ($resp) = HEAD($path);
+ my ($content_type) = $resp->header("Content-Type");
+ my ($expected) = shift;
+ ok t_cmp($expected,
+ $content_type, "Testing error response on $path");
+}
Index: perl-framework/t/conf/error_charset.conf.in
===================================================================
RCS file: perl-framework/t/conf/error_charset.conf.in
diff -N perl-framework/t/conf/error_charset.conf.in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ perl-framework/t/conf/error_charset.conf.in 17 Dec 2003 23:11:32 -0000
@@ -0,0 +1,9 @@
+##
+## suppress-error-charset test config
+##
+
+<IfModule mod_env.c>
+ <Directory @SERVERROOT@/htdocs/error_charset>
+ SetEnv suppress-error-charset true
+ </Directory>
+</IfModule>
--
Yoshiki Hayashi