Alex Menendez ([EMAIL PROTECTED]) said something to this effect:
> 
> does anyone know how to get the output of a standalone cgi script from a
> mod_perl module
> 
> I have tried all the subrequest stuff but I can't get it to work.

If all you are trying to do is get the raw output, use LWP and a virtual
server running on localhost:

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
package Apache::CGIGetter;

use vars qw($agent);
use constant HOST => 'http://localhost';

use Apache::Constants 'OK';
use LWP::UserAgent;
use HTTP::Request;

BGEIN { $agent = LWP::UserAgent->new(); }

sub handler {
    my($r) = @_;
    my $url = join '/',HOST,$r->uri;
    if(my $args = $r->args) { $url .= "?$args"; }

    # These lines are taken from pp. 376-377 of the Eagle book
    # http://www.modperl.com/book/chapters/ch7.html#Handling_the_Proxy_Process_Ourse

    my $request = HTTP::Request->new($r->method, $url);
    $r->headers_in->do(sub { $request->header(@_) });
    if($r->method eq 'POST') {
        my $len = $r->header_in('Content-length');
        my $buf;
        $r->read($buf,$len);
        $request->content($buf);
    }

    my $result = $agent->request($request);

    # $cgi_content will contain the body of the resulting page, i.e.,
    # the HTML page.
    my $cgi_content = $result->content;

    # Do stuff here with $cgi_content.

    return OK;
}
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

In the httpd.conf:

<FilesMatch "\.cgi$">
    SetHandler  perl-script
    PerlHandler Apache::CGIGetter
</FilesMatch>

And a virtual host on 127.0.0.1, running mod_cgi as usual.

Good luck.

(darren)

-- 
He who would trade liberty for safety deserves neither.

Reply via email to