Apache-ProxyStuff
view release on metacpan or search on metacpan
ProxyStuff.pm view on Meta::CPAN
# Mangle the url for the file as needed
my ($null, $base, $uri);
if ($strip_host) {($null, $base, $uri) = split /\//, $r->uri, 3}
else {$uri = $r->uri}
$uri =~ s/^\///; # Remove leading slashes
my $file_uri = join '/', $proxy_prefix, $uri;
$file_uri .= q(?) . $r->args if $r->args;
$r->log->debug("URI: $file_uri");
# Build the request
my $req = new HTTP::Request($r->method => $file_uri);
# Set headers
$req = set_headers($req, $r->headers_in);
# Copy POST data, if any
if ($r->method eq 'POST') {
my $len = $r->header_in('Content-length');
my $buf;
$r->read($buf, $len);
$req->content($buf);
ProxyStuff.pm view on Meta::CPAN
return OK;
} # End if
# Get the content
my $content = $res->content_ref;
# If it's text
if ($r->content_type =~ /^text/) {
# Get the header and footer
my $header_req = new HTTP::Request('GET' => $header_file);
my $footer_req = new HTTP::Request('GET' => $footer_file);
$header_req = set_headers($header_req, $r->headers_in);
$footer_req = set_headers($footer_req, $r->headers_in);
$header_req->push_header('REAL_URI' => $file_uri); # Somebody might need the real page
$footer_req->push_header('REAL_URI' => $file_uri); # Ditto
$header_req->push_header('ORIG_URI' => $r->uri); # Somebody might need the real page
$footer_req->push_header('ORIG_URI' => $r->uri); # Ditto
my $header_res = $UA->request($header_req);
my $footer_res = $UA->request($footer_req);
# Adjust the content length to include the lenght of the header and footer
( run in 0.651 second using v1.01-cache-2.11-cpan-de7293f3b23 )