Skip to content

Instantly share code, notes, and snippets.

@zoul
Created November 15, 2011 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoul/1367925 to your computer and use it in GitHub Desktop.
Save zoul/1367925 to your computer and use it in GitHub Desktop.
Simple debugging HTTP proxy in Perl
#!/usr/bin/env perl
use Modern::Perl;
use HTTP::Proxy;
use HTTP::Proxy::HeaderFilter::simple;
my $proxy = HTTP::Proxy->new(host => undef, port => 3128);
my $filter = HTTP::Proxy::HeaderFilter::simple->new(sub
{
my ($self, $headers, $message) = @_;
my $is_response = (ref $message) =~ /Response/;
my $leader = $is_response ? '<' : '>';
print $leader x 80, "\n";
print $message->as_string;
});
$proxy->push_filter(request => $filter, response => $filter);
$proxy->start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment