perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: HTTP Response Headers fixup
Date Thu, 01 Jan 2009 20:26:13 GMT
Torsten Foertsch wrote:
> On Thu 01 Jan 2009, André Warnier wrote:
>> Unfortunately the Content-Type header is a different beast. Inside
>> Apache it is not only a response header, but a more complex data
>> type. You can set a different Content-Type header with mod_headers,
>> but since the internal structure remains unchanged it will be
>> overwritten again by Apache.
>>
>> As a result I see no way to change an existing character set in a
>> Content-Type header.
> 
> Try to create a request output filter that sets $r->content_type, 
> removes itself and returns DECLINED.
> 
Torsten, you're the greatest.
It works perfectly, even without having the filter remove itself (which 
I did not know how to do).

Here is the minimal filter :

package AM::FixupContentType;
# Fixes bad servlet-generated Content-Type header, when used in 
iso-latin-2 environment.
# Idea from Torsten Foetsch.

$AM::FixupContentType::VERSION = '0.01';

use strict;
use warnings FATAL => 'all';
use mod_perl2 2.000001;
use base qw(Apache2::Filter);
use Apache2::Const ();

sub handler : FilterRequestHandler {
my ($f, $bb) = @_;
     $f->r->content_type("text/html; charset=ISO-8859-2");
     return Apache2::Const::DECLINED;
}
1;



Mime
View raw message