If you're using the stream API like this you'll never see the headers in
$buffer. =20

I think you would have to modify them using $f->r (the request object),
then abuse the headers_out and/or err_headers_out tables.

I'm not sure if this is the case for the bucket brigade API or not (i've
never used it)

You should also note that if you were going to run a regexp like that
you'd need to handle the cases where the token you were trying to
substitute was split by a read.

You can take a look at Apache2::Filter::TagAware on CPAN, which was
built based on a talk that Geoff Young gave a couple years ago at
ApacheCon. his slides are here:=20

There are also some other Filter's on CPAN you could take a look at.


-----Original Message-----
From: J Amuse [mailto:jamuse@gmail.com]=20
Sent: Thursday, January 31, 2008 9:17 AM
To: modperl@perl.apache.org
Subject: output filters

I'm trying to write a filter using modperl that will update parts of the
server response on the fly. My first attempt was to rewrite the path
setting in the server's set cookie response to set the path to:
path=3D/NewPath. After copying and pasting some examples I came up with
the following:
package Apache2::RewriteCookiePath;
use strict;
use warnings;
use Apache2::Filter ();
use Apache2::RequestRec ();
use APR::Table ();
use Apache2::Const -compile =3D> qw(OK);
use constant BUFF_LEN =3D> 1024;

sub handler {
my $f =3D shift;

while ($f->read(my $buffer, BUFF_LEN)) {
$buffer =3D~ s/path=3D\//path=3D\/NewPath/g;

return Apache2::Const::OK;

I have not been able to get this code to work. How can I call this code
from a virtual host's config file so that it applies to all cookies set,
no matter what subdirectory is requested? This is my first attempt with
mod-perl, so any pointers would be really helpful.