dorp has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have a CGI script that reads in data sent by the POST method. How can I pass along this data, using the POST method again, to another CGI script? I've looked around, and so far as I can discern, people just talk about using STDIN or saved files to pass along data. My data is too big to fit into STDIN, and saved files would slow it down.

Replies are listed 'Best First'.
Re: how to re-post data to another CGI?
by jepri (Parson) on Aug 08, 2001 at 04:50 UTC
    The trick is to pretent that you are another browser, and acccess the other cGI script over HTTP, just like a browser does. There is a module for it, it's called LWP.

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

Re: how to re-post data to another CGI?
by trantor (Chaplain) on Aug 08, 2001 at 10:19 UTC

    You may want to have a look at this document for a comprehensive discussion about POST redirection.

    It's feasible as other monks pointed out, but you must be aware of caveats and possible consequencies.

    -- TMTOWTDI

Re: how to re-post data to another CGI?
by thatguy (Parson) on Aug 08, 2001 at 07:21 UTC
    you could do a redirect to the second script and have that script look for the info. If you do that then you can have a redirect that works in the headers:
    if ($foo eq "successfull") { print $query->redirect(-location=>'http://example.com/cgi-bin/seco +ndscript.pl?foo1=$foo1&foo2=$foo2',-nph=>1); exit; }

    or in the body (the Content-type is only needed if you havent printed your headers)

    print "Content-type: text/html\n\n"; print <META HTTP-EQUIV=refresh CONTENT="0;URL=http://example.com/cgi-b +in/secondscript.pl?foo1=$foo1&foo2=$foo2">

    -p