| 19/38 |
© 2004 by Philippe "BooK" Bruhat.
|
Several "standard" filters are shipped with HTTP::Proxy.
One of them is the HTTP::Proxy::BodyFilter::tags filter, which makes sure that subsequent filters will not receive an incomplete HTML tag
And now our simple filter just works:
$proxy->push_filter( host => 'example.com', response => HTTP::Proxy::BodyFilter::tags->new(), response => HTTP::Proxy::BodyFilter::simple->new( sub { ${$_[1]} =~ s!<(/?)em\b!<$1i!g; } ) );
When the HTTP::Proxy::BodyFilter::tags filter finds a < bracket
without the matching >, it prevents the last piece of data to be sent
to the next filter in the chain
The missing bit is prepended to the next chunk of data going through the filters