print "Location: [www\.site\.com...]
but, for security reasons (the newcgi.pl is my bank's page accepting payments) I'd like to avoid parameters be showed in the url.
I wonder if the client could only read the address of the new page (that of my bank) while parameters are sent invisibly to it by my perl script.
Does anyone know if it is possible?
thanks
What you want to do is make a POST request to the other CGI script. This is basically the same as accessing a CGI script through an HTML form.
Here's a way to do it:
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
my $req = POST 'http://www.perl.com/cgi-bin/BugGlimpse',
[ search => 'www', errors => 0 ];
print $ua->request($req)->as_string;
(The above was taken from the LWP Cookbook, published here: [search.cpan.org...] )
In the above example, the data they are posting is this:
search => 'www', errors => 0
They are sending two fields: 'search' and 'errors'. The data those fields refer to is, respectively, 'www' and '0'. To add more fields/data, you'd simply put another comma after the last piece of data and specify a new field name, followed by a '=>', followed by the data.
It's important to URL-encode the fieldnames and data, just like you would for a GET request (the request you gave in your example).
Dan
To have a correct header I replaced the line:
print $ua->request($req)->as_string;
with (I found it somewhere else):
my $output = $ua->request($req)->as_string;
$output =~ s!^HTTP/\d+\.\d+!Status:!;
print $output;
and it works good.
Anyway I'm afraid it doesn't solve the problem.
There's no redirection.
I mean it seems that (if I got it correctly reading cpan lwpcook) it is my script that first receive the bank's page and then send it to the browser.
That's why my browser never shows the bank's page address.
Due to the nature of information received by the bank's page (e.g. credit card numbers) I'd like not to be that sort of mediator between client and bank when processing such data.
Is it possible redirect + send parameters + hide parameters?
thank you again
Your example is also a little wierd - a script at a bank accepting payment info over a non-secure connection? Using a GET request? I find that quite hard to believe; and even if it's true, you don't want to do things that way. Talk to the bank, see what they say.
About my example, you're right, that was just an example.
The real address is:
[select.worldpay.com...]
I just wanted to skip that step.
thank you anyway