Skip to content

Instantly share code, notes, and snippets.

@soh335
Created April 29, 2010 15:47
Show Gist options
  • Save soh335/383799 to your computer and use it in GitHub Desktop.
Save soh335/383799 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Plack::Request;
use Data::Dumper;
use LWP::UserAgent;
return sub {
my $req = Plack::Request->new(shift);
my $_req = HTTP::Request->new( $req->method,
$req->request_uri,
$req->headers,
$req->raw_body
);
my $ua = LWP::UserAgent->new;
my $res = $ua->request( $_req );
my @res_header;
$res->headers->scan(sub{
push @res_header, @_;
});
[ $res->code, \@res_header, [$res->content] ];
};
plackup -s AnyEvent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment