/usr/share/doc/libhttp-proxy-perl/examples/outline.pl is in libhttp-proxy-perl 0.304-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #!/usr/bin/perl -w
use HTTP::Proxy qw( :log );
use HTTP::Proxy::BodyFilter::htmlparser;
use HTML::Parser;
use strict;
my $parser = HTML::Parser->new( api_version => 3 );
$parser->handler(
start_document => sub { my $self = shift; $self->{print} = 1 },
"self"
);
$parser->handler(
start => sub {
my ( $self, $tag, $text ) = @_;
$self->{print} = 1 if $tag =~ /^h\d/;
$self->{output} .= $text if $self->{print};
$self->{print} = 0 if $tag eq 'body';
},
"self,tagname,text"
);
$parser->handler(
end => sub {
my ( $self, $tag, $text ) = @_;
$self->{print} = 1 if $tag eq 'body';
$self->{output} .= $text if $self->{print};
$self->{print} = 0 if $tag =~ /^h\d/;
},
"self,tagname,text"
);
$parser->handler(
default => sub {
my ( $self, $text ) = @_;
$self->{output} .= $text if $self->{print};
},
"self,text"
);
my $filter = HTTP::Proxy::BodyFilter::htmlparser->new( $parser, rw => 1 );
my $proxy = HTTP::Proxy->new(@ARGV);
$proxy->push_filter( mime => 'text/html', response => $filter );
$proxy->start;
|