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

Thanks to injunjoel and Crackers2 for helping me figure this out.
. In an earlier post, I'd asked how to pass POST data off to different CGI scripts, depending on the user input. I was pointed to using redirect. But I couldn't get it to pass the POST data correctly. In the CB, I found out that:
  1. According to subdir.com, the original www standard said that, upon encountering a redirect, browsers should re-submit the request to the new address with the POST data unchanged.
  2. But browsers (except Lynx) don't do this correctly and servers don't generally handle it right, anyways.
  3. If you are passing a small amount of data, it can be munged into the URI of the redirect (which will have a REQUEST_TYPE of GET):
    Status: 302 Moved Location: http://example.com/target.html?color=blue&media=crayon
  4. If you're needing to pass larger amounts of data, or if you're not wanting to pass it in a GET for other reasons (like form-spoofing security issues) then you're probably trying to cobble together a session. Use CGI::Session instead.

Update: fixed link to cgi::session

throop

Replies are listed 'Best First'.
Re: What I learned about passing POST data through a CGI redirect
by saberworks (Curate) on Sep 13, 2007 at 20:13 UTC
    If you're using mod_perl and you want to redirect to another script on your own site, you can use the internal_redirect method of the Apache->request object.