File: post.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 (27 lines) | stat: -rwxr-xr-x 852 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
23
24
25
26
27
#!/usr/bin/perl -w
use strict;
use HTTP::Proxy qw( :log );
use HTTP::Proxy::BodyFilter::simple;
use CGI::Util qw( unescape );

# NOTE: Body request filters always receive the request body in one pass
my $filter = HTTP::Proxy::BodyFilter::simple->new(
    sub {
        my ( $self, $dataref, $message, $protocol, $buffer ) = @_;
        print STDOUT $message->method, " ", $message->uri, "\n";

        # this is from CGI.pm, method parse_params
        my (@pairs) = split ( /[&;]/, $$dataref );
        for (@pairs) {
            my ( $param, $value ) = split ( '=', $_, 2 );
            $param = unescape($param);
            $value = unescape($value);
            printf STDOUT "    %-30s => %s\n", $param, $value;
        }
    }
);

my $proxy = HTTP::Proxy->new(@ARGV);
$proxy->push_filter( method => 'POST', request => $filter );
$proxy->start;