On Sat, 9 May 1998 12:49:56 +0100, Andrew Philip Crook
<shu96apc@reading.ac.uk> wrote:
>
>How can pop11 send and receive CGI requests?
>
>Andrew Crook.
>
I'm not an expert on this, but AFAIK, the HTTP/CGI
protocol can be used with any language that can
read from standard input and write to standard
output. Pop11 can certainly do that!
As far as I understand it, you put your CGI
program in the cgi-bin directory used by the
web server, and have a URL that links to
it, e.g. cgi-bin/myprog?rhubarb
would run the program myprog.
Actually, my experience is that it may not be quite
that simple. Some URLs can cause the parameters
to be passed as command line arguments to your
CGI program. So, cgi-bin/myprog?rhubarb would
actually pass "rhubarb" as a command line argument.
So you would arrange that "myprog rhubarb" runs
your program and does what you want. This works
for me with a .exe file on a Windows NT machine
running Microsoft Personal Web Server. I also
found that the output (written to standard
output) required some http header information
before the html stuff, otherwise I got
an http protocol error. I avoided this by
including the following 3 lines in the output
of the program:
HTTP/1.1 200 OK
Content_type: text/html
The third line was a blank line, and then the
HTML stuff followed. You could do this in pop11
with:
pr('HTTP/1.1 200 OK\nContent_type: text/html\n\n');
I've no idea how standard the Microsoft Personal
Web Server is for CGI -- all the documentation I
could find seemed to be encouraging me to use
some proprietary Microsoft alternative :-).
But these are fiddly details -- the short answer
is "it should be quite easy, but you are going
to have to read up on the HTTP/CGI stuff".
I got what little information I know about CGI
from a book about something else, so it may not
be the best reference. But FWIW, the reference
is:
Client Server Programming with Java and CORBA,
by Robert Orfali and Dan Harkey (1st edition). It
is in Chapter 11, pp209-238. The corresponding
part of the 2nd edition is pp231-254, so I guess
there must be three or four pages of new material
which I haven't read yet.
Jonathan
p.s. I've been assuming you want to write a pop11
program which is called by the web server. If,
in fact, you are writing a web-server in pop11,
then you simply need to run the CGI program from
pop11, setting up a few environment variables
and arranging to send the appropriate stuff to
the standard input of the CGI program and reading
the answer back from its standard output. For
the details of _what_ to send, you'll have to
read up on CGI, or ask in an appropriate ng.
For _how_ to send it, you could ask again here
with a more specific question.
If you _are_ writing your own web-server in
pop11, you may ask yourself _why_ you want to
run CGI scripts. Chances are you could do
everything you wanted within poplog more easily.
(It would be supremely easy to allow your
customers to write servlets in pop11, and for
the poplog-based web-server to autoload them
as needed.)
Without more knowledge of what you want to
do, it is impossible to give more specific help.
--jlc
|