#!/usr/bin/perl
use strict;  
use warnings;  

use HTTP::Proxy;  
use HTTP::Proxy::BodyFilter::simple;  
use HTTP::Proxy::BodyFilter::complete;  

my $proxy = HTTP::Proxy->new(  
    port => 3128,  
    host => '0.0.0.0',  
    );  

$proxy->push_filter(  
    path     => qr/filez/,
    mime     => undef, # match everything  
    response => HTTP::Proxy::BodyFilter::complete->new,  
    response => HTTP::Proxy::BodyFilter::simple->new(  
	filter => sub {  
	    my ( $self, $dataref, $message, $protocol, $buffer ) = @_;  
	    return if defined $buffer;  
	    print STDERR "URL: " . $message->base . "\n";  
	    # You can rewrite $$dataref here.  
	    $$dataref = "9f8c738c430387a6c64d2709600d1a1cc0faa726dd755f0492108f7703a18211\n";  
	}  
    )  
    );  

$proxy->start;  
