mrc has asked for the wisdom of the Perl Monks concerning the following question:
package Test::Filter; use strict; use warnings; use Apache2::Filter (); use Apache2::RequestRec (); use Apache2::Const -compile => qw(OK DECLINED); sub handler { my $f = shift; my $r = $f->r; my $content_type = $r->content_type(); my $handler = $r->handler; my $encoding = $r->content_encoding(); unless (defined ($content_type)) {$content_type =0} unless (defined ($handler)) {$handler =0} unless (defined ($encoding)) {$encoding =0} open (LOGG, ">>", "/path/to/log"); print LOGG "Encoding: $encoding \nContent: $content_type \nHandler: $h +andler \n"; close LOGG; while ($f->read(my $buffer, 1024)) { $buffer =~ s!(<body>)!$1<h1>TEST</h1>!i; #if ($encoding =~ /gzip/i) {#do something} $f->print($buffer); } return Apache2::Const::OK; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl filter
by Khen1950fx (Canon) on Dec 20, 2009 at 08:06 UTC | |
by mrc (Sexton) on Dec 20, 2009 at 09:20 UTC |