When I access the Wikipedia Perl page through this proxy, it delivers the page but it does not substitute Perl with PERL.#!/usr/bin/perl -w use HTTP::Proxy; use HTTP::Proxy::BodyFilter::simple; use HTTP::Proxy::BodyFilter::complete; my $proxy = HTTP::Proxy->new; # pass the complete response body to our filter (in one pass) $proxy->push_filter( mime => 'text/html', response => HTTP::Proxy::BodyFilter::complete->new, response => HTTP::Proxy::BodyFilter::simple->new( sub { my ( $self, $dataref, $message, $protocol, $buffer ) = @_; $dataref =~ s/Perl/PERL/; } ) ); $proxy->start;
It seems like the target of the substitution statement should be the right one because related docs say "$dataref is a reference to the chunk of body data received." I also tried changing the target to ${ $_[1] } as suggested here but that doesn't work either. The debugger indicates there is nothing like HTML in either of those variables.
So what am I doing wrong?
BTW my eventual goal is to intercept the html, parse/modify it with HTML::TreeParser, then send the modded data back to the client, if that mattes. But I thought I should start with something simple.
TIA
Steve
In reply to HTTP::Proxy::BodyFilter Shezza No Voik by cormanaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |