if I want to modify HTTP response header in OutputFilter phase, I
should configure httpd.conf as PerlOptions +GlobalRequest, and then I
can get $r with Apache->request.
Am I right in saying this?
P.S. Following code is any to any encoding filter, paticulary useful
in development for co-existence with PC browsers and Japanese phone
browsers, etc.
package Slasher::EncodingFilter;
use strict;
use Apache::RequestRec ();
use Apache::RequestIO ();
use Apache::Filter ();
use Encode;
use I18N::Charset;
use Apache::Const -compile => 'OK';
sub handler {
my $filter = shift;
my $r = Apache->request;
my($from, $to) = map $r->dir_config($_), qw(EncodingFrom EncodingTo);
my $charset = iana_charset_name($to);
$r->content_type("text/html; charset=$charset");
while ($filter->read(my $buffer, 1024)) {
Encode::from_to($buffer, $from, $to);
$filter->print($buffer);
}
return Apache::OK;
}
1;
__END__
PerlModule Slasher::EncodingFilter
<Location /charset>
PerlSetVar EncodingFrom euc-jp
PerlSetVar EncodingTo utf8
PerlOptions +GlobalRequest
PerlOutputFilterHandler Slasher::EncodingFilter
</Location>
--
Tatsuhiko Miyagawa <[EMAIL PROTECTED]>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]