[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    RE: output filters
From:       "Adam Prime x443" <aprime () brunico ! com>
Date:       2008-01-31 15:32:30
Message-ID: B09F664DB94787409108507B14156C380208553D () exchange2 ! brunico ! com
[Download RAW message or body]

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

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: 
http://www.modperlcookbook.org/~geoff/slides/ApacheCon/2006/mp2_filters-
printable.pdf.gz

There are also some other Filter's on CPAN you could take a look at.
http://search.cpan.org/search?query=Apache2%3A%3AFilter&mode=all

Adam

-----Original Message-----
From: J Amuse [mailto:jamuse@gmail.com] 
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=/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 => qw(OK);
use constant BUFF_LEN => 1024;

sub handler {
my $f = shift;

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

return Apache2::Const::OK;
}
1;

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.

Thanks



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic