Apache-RewritingProxy
view release on metacpan or search on metacpan
RewritingProxy.pm view on Meta::CPAN
my $browser = $r->header_in('User-Agent');
$ua->agent($browser);
# We have to append the query string since it got munged by
# apache when this was first requested.
my $rurl = $url;
$rurl .= "?". $r->args if ($r->args && $url !~ /\?/);
if ($r->method eq 'GET')
{
$req = new HTTP::Request 'GET' => "$rurl";
$req->header('Referer'=>"$referer");
$serverCookies->add_cookie_header($req);
# This needs to be a simple request or else the redirects will
# not work very nicely. LWP is too smart sometimes.
$res = $ua->simple_request($req);
}
elsif ($r->method eq 'POST')
{
# This is a little bit of tricky ju ju here.
# We will use another PERLy package to
# prepare the URL and pack in the encoded form data.
use URI::URL;
my %FORM;
$req = new HTTP::Request 'POST' => "$rurl";
$req->header('Referer'=>"$referer");
$req->content_type('application/x-www-form-urlencoded');
$serverCookies->add_cookie_header($req);
# $req->content('$buffer');
my $pair;
my @pairs = split (/&/, $r->content);
# TODO: This next bit more efficiently.
# It works for the occasional cgi, but not for constant
# hammering away at this code. There has to be a better
# and more OOP way.
( run in 0.338 second using v1.01-cache-2.11-cpan-de7293f3b23 )