HTTP::Proxy::BodyFilter::Adnix - Automatically block advertising images with custom regexes
use HTTP::Proxy::BodyFilter::Adnix # Use default blacklist rules and default placeholder image $proxy->push_filter( mime => 'image/*', response => HTTP::Proxy::BodyFilter::Adnix->new(); ); # OR ... # You must supply your custom rules for filtering my $filter = HTTP::Proxy::BodyFilter::Adnix->new( deny => [ 'spammingserver.com', 'WeSpamYou.org', ... ], image => 'http://www.mydomain.com/mylogo.png' ); $proxy->push_filter( mime => 'image/*', response => $filter );
This class acts as a plugin filter module for HTTP::Proxy distribution. Its purpose is to block advertising (but you can define it) images to avoid wasting bandwidth for these images.
HTTP::Proxy::BodyFilter::Adnix filter module is based on
HTTP::Proxy::BodyFilter class that is part of
This filter tries to detect advertising images into your HTTP requests, and it replaces them with an image of your choice. Detection is done through a set of regular expression you can customize.
If you're wondering where the name
Adnix comes from, you should really read the wonderful book Contact by Carl Sagan.
For more detailed information on
HTTP::Proxy::BodyFilter, see its documentation on CPAN.
None by default.
Internal. Gets called on filter initialization. Accepts the options that customize filter behaviour.
String. Filesystem path to PNG image to be used as a placeholder for all detected advertising images.
Array reference. Must contain all regular expressions that block images. This means that if the current image matches any of these regular expressions, it will be blocked.
This is where the hard work gets done. Every image is matched against a set of regexes and if it matches any of these, it is not downloaded and its content is replaced by the placeholder image.
The intention here is to save bandwidth and to remove those annoying banners.
Internal function. Tries to load the image to be used as a placeholder for all advertising images. If no remote/local image can be loaded, an hardcoded binary PNG image is used.
For more information, you should read
HTTP::Proxy distribution documentation. If you find this class useful or want to report complaints or bugs, please do it through the good CPAN bug report system on http://rt.cpan.org.
This class has been derived from original work by Philippe "Book" Bruhat, author of HTTP::Proxy distribution. Go check out his good work!
Cosimo Streppone <firstname.lastname@example.org>
Copyright 2004 by Cosimo Streppone
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.