Unfortunately, I am not familiar with Perl, so please here. I actually use FCGI with Perl.
I need 1. accept the POST request → 2. send it via POST to another URL → 3. get the results → 4. return the results to the first POST request (4 steps).
To accept the POST request (step 1), I use the following code (found it somewhere on the Internet):
$ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}
else {
print ("some error");
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%(..)/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
The content $name(this is a line) is the result of the first step. Now I need to send $namevia a POST request to some_url (step 2), which returns another result (step 3), which I should return as a result to the very first POST request (step 4).
Any help with this would be greatly appreciated.
Thank.