1#!/usr/bin/perl -w
2use HTTP::Proxy qw( :log );
3use HTTP::Proxy::BodyFilter::lines;
4use HTTP::Proxy::BodyFilter::simple;
5use strict;
6
7my $proxy = HTTP::Proxy->new(@ARGV);
8
9# a simple proxy that trims whitespace in HTML
10$proxy->push_filter(
11    mime => 'text/html',
12    response => HTTP::Proxy::BodyFilter::lines->new(),
13    response => HTTP::Proxy::BodyFilter::simple->new(
14        sub {
15            my ($self, $dataref ) = @_;
16            $$dataref =~ s/^\s+//m; # multi-line data
17            $$dataref =~ s/\s+$//m;
18        }
19    )
20);
21
22$proxy->start;
23