HOW TO: Doing a POST with www'request

Ramon M Felciano (felciano@camis.stanford.edu)
Sat, 3 Feb 96 20:53:54 -0800


Hello --

I'm trying to simulate a POST process from within a script. It seems like this
ought to be trivial, since I can grab an existing form that works, switch the
CGI for that form to a generic.pl CGI that simply prints the variables. Thus I
can see what data is being sent to the CGI I'm interested in. From there, it
should be a short trip to translating those variables to the parameters of a
POST request.

However, using libwww, I'm not clear what fields the caller (me) needs to fill
in and which ones are filled in by the "request" function. For example, if I
want something like this to be sent to the server:

     POST /cgi-bin/lit-search-cgi HTTP/1.0
     Content-type: application/x-www-form-urlencoded
     Content-length: 35

     author=felciano&subject=architecture

What should my call to request look like? The $method and $url parameters are
trivial. I think the $content parameter should simply be:

     $content = "author=felciano&subject=architecture";

What about the %headers parameter? The only one the documentation shows is
'User-Agent'. Do I need to fill in the 'Content-type' or 'Content-length' ones,
or will www'request do that for me?

Thanks.

Ramon Felciano
Section on Medical Informatics
Stanford University