File: trim.pl

package info (click to toggle)
libhttp-proxy-perl 0.304-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 720 kB
  • sloc: perl: 2,576; makefile: 4
file content (22 lines) | stat: -rwxr-xr-x 552 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl -w
use HTTP::Proxy qw( :log );
use HTTP::Proxy::BodyFilter::lines;
use HTTP::Proxy::BodyFilter::simple;
use strict;

my $proxy = HTTP::Proxy->new(@ARGV);

# a simple proxy that trims whitespace in HTML
$proxy->push_filter(
    mime => 'text/html',
    response => HTTP::Proxy::BodyFilter::lines->new(),
    response => HTTP::Proxy::BodyFilter::simple->new(
        sub {
            my ($self, $dataref ) = @_;
            $$dataref =~ s/^\s+//m; # multi-line data
            $$dataref =~ s/\s+$//m;
        }
    )
);

$proxy->start;