#!/usr/local/bin/perl -w
###########################################
# proxy-logger - A simple logging proxy
# Mike Schilli, 2012 (m@perlmeister.com)
###########################################
use strict;
use HTTP::Proxy;
use HTTP::Proxy::HeaderFilter::simple;
use HTTP::Request::Common;

my $proxy = HTTP::Proxy->new( 
    host => "192.168.1.123", 
    port => 9999 );

my $repl = "http://perlmeister.com/test/" .
           "sandy-beach.jpg";

$proxy->push_filter(
  request => 
    HTTP::Proxy::HeaderFilter::simple->new(
      sub { 
        my( $self, $headers, $req ) = @_;  

        if( $req->uri() =~ 
                /eviladserver\.com/ ) {
          $_[2] = GET $repl;
        }
      }
    )
);

$proxy->start;
