[Catalyst] Authenticating a "Normal CGI Script" Inside a Catalyst Application

hkclark at gmail.com hkclark at gmail.com
Sat Jan 28 02:52:09 CET 2006


Thanks.  Excellent information.

For some reason my call to "$stdout = $c->stdout;" (after the CGI.pm stuff
has generated the HTML output) doesn't seem to get anything back in the
"$stdout->getline" loop, but I'll keep playing with it.

Thank you again for your kind assistance (and your work on the Catalyst
project!).

On 1/27/06, Yuval Kogman <nothingmuch at woobling.org> wrote:
>
> On Fri, Jan 27, 2006 at 20:09:11 -0500, hkclark at gmail.com wrote:
> > Hi Yuval,
> >
> > Thank you very much for the suggestions.  I have been taking a look at
> > HTTP::Request::AsCGI and have a few questions:
> >
> > 1) It seems the whole idea of HTTP::Request::AsCGI is to essentially
> grab
> > what CGI.pm would normally send to stdout and capture it in a string
> > variable -- is that correct?  I assume the idea with Catalyst would be
> to
> > assign this captured output to something like $context->response->body
> so
> > that it goes back to the user.  Or am I totally missing the boat here?
>
> You are correct, but it's not only that - HTTP::Request::AsCGI also
> takes an HTTP::Request object (presumably Catalyst::Request can be
> fudged into one - ask sri on how) and sets up an environment in
> which a CGI script can be executed and the results can be gathered.
>
> This includes everything from $ENV{QUERY_STRING} to localized STDIN
> and STDOUT.
>
> >
> > 2) This could be a really dumb question, but when I look at the
> "Synopsis"
> > example in:
> >
> http://search.cpan.org/~chansen/HTTP-Request-AsCGI-0.5/lib/HTTP/Request/AsCGI.pm
> > I'm confused by what a GET request to http://www.host.com has to do with
> > capturing the output of the CGI.pm header, start_html, h1, and end_html
> call
> > a few lines later.  I see that $request is used in the AsCGI
> constructor,
> > but it seems totally unnecessary and unrelated.  What am I missing here?
>
> The SYNOPSIS section takes the HTTP::Request object created using
> ->new( GET => $uri ), and then uses that to create an environment
> using the HTTP::Request::AsCGI object.
>
> When CGI->new is created, CGI will look at the environment, and be
> fooled into thinking that it's serving the request for
> "http://www.host.com/".
>
> Then, after 'my $c' goes out of scope the environment is restored,
> and the while loop prints out the output of the CGI script to the
> real stdout.
>
> The point is that CGI->new could happen in an entirely different
> process - HTTP::Request::AsCGI sets up the environment to act as if
> it was an HTTP server that is handling a CGI script.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20060127/ab249a2d/attachment.htm


More information about the Catalyst mailing list