Click to See Complete Forum and Search --> : REDIRECT Including POST Parameters


rigadon
05-13-2006, 03:33 AM
Hi everyone!

I don't suppose this is strictly a Perl related issue but I am developing in Perl and I don't know where else to put this post so please humour me :)

Does anyone know how I can include POST parameters in a REDIRECT? I have a form which POSTs to a page that REDIRECTS elsewhere. I've tried formatting the parameters into the REDIRECT URL but my server seems to have issues with passing lots of data in the URL. Ideally I'd like to include the POST parameters directly in the REDIRECT body but I don't know if this is possible?

Thanks
Jay

Nedals
05-13-2006, 09:12 PM
Take a look at LWP::UserAgent.
http://search.cpan.org/search?query=lwp%3A%3AUserAgent&mode=all

rigadon
05-14-2006, 01:39 PM
Thanks for replying Nedals!

I've used LWP::UserAgent in the past, but I cannot see how it can help me here! Please can you explain how you intended me to use this module?

Thanks
Jay

Nedals
05-14-2006, 02:30 PM
When you use REDIRECT, the data is sent via a GET which is limited to 2k bytes (or is it 4k?). That's why you need LWP.

script1

Get posted data and set the LWP'd names and values as needed.
....
my $ua = LWP::UserAgent->new();
my $response = $ua->post(
'script2_url',
{
'name1' => 'value1',
'name2' => 'value2',
'name3' => 'value3',
}
);
....
The response may be an HTML page, in which case, you can display it or your response could be 'true|false' (or whatever you want assuming you have control over script2), in which case, script1 can display the appropiate page.

Any help?

rigadon
05-15-2006, 02:46 AM
Ah I see - so instead of redirecting I am calling the page through LWP::UserAgent instead? Then I can display the output using my original script? I'll give that a go and see if works for me - thanks Nedals!