develooper Front page | perl.libwww | Postings from November 2001

Re: CGI harness, anyone?

Thread Next
From:
Steve Fink
Date:
November 17, 2001 03:28
Subject:
Re: CGI harness, anyone?
Message ID:
20011116164216.F16204@foxglove.digital-integrity.com
> Has anyone done a CGI protocol module?  No, not CGI.pm.  The *server*
> side of the protocol!

> So, has anyone thought about this?  Tackled this?  Completed this?
> Documented this?

Here's a response a year later. (First time I'm reading the libwww
archives.) Raphael Manfredi has done this with CGI::Test. It doesn't
do quite what you want, though.

> The API should have lots of defaults... at a bare minimum,
> specifying the form data,

Check.

> but also allowing to say whether we're simulating GET/POST,

Check.

> how to deal with non-zero exits and STDERR,

I don't think so.

> how to deal with Location: headers,

No, but see below.

> provide hooks for file uploads,

Check.

> Maybe it should take a HTTP::Request as an input value, and return
> an HTTP::Response (or would that be overkill?). In fact, maybe it
> can be a special subclass of LWP::UserAgent which recognizes a
> particular server as being local, or a scheme type of "cgi:".

It currently doesn't use any of the HTTP:: or LWP:: classes. I have a
local version that I've turned inside out. It registers an
LWP::Protocol subclass as the handler for 'http', and then looks at
incoming requests and decides which ones to handle internally and
which ones to delegate to LWP::Protocol::http. Internal ones fork()
and set up the CGI environment variables and input.

It passes the CGI::Test suite now, but plays some ugly games to access
Net::HTTP functionality:

    bless $socket, 'Net::HTTP'; # $socket is an IO::File
    $socket->_rbuf('');
    ${*$socket}{http_request_method} = [ $request->method ];

I'll run it by Raphael first to see what he thinks.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About