Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

POSTing in Apache

Status
Not open for further replies.

jat12

Programmer
Oct 4, 2002
1
AU
Hi there,

I had my apache setup working fine - running Perl applications perfectly.
However, suddenly my Perl scripts are not working correctly. The scripts execute but they do not receive ANY POST data.

If I access the scripts via a GET request the form data is passed incorrectly, but any POST operations do not work (no data is received). If I print out the REQUEST_METHOD in ENV I correctly get POST. But printing out the QUERY_STRING I get nothing (an empty string). However, the correct query string is printed for GET requests.

There is no problem with my Perl scripts, and I have tried different ways & scripts of extracting the form data (cgi-lib.pl, manually, etc). The only change that has occurred to my apache conf is that I am listening port 81 -but even if I change it back to port 80 it still doesnt work (when it
used to!).

Your help is much appreciated.

 
When you send a POST request to a script, Apache doesn't put the values in QUERY_STRING, it sends them to the scripts STDIN. So you would want something like this:
Code:
my $values = "";
if ($ENV{'REQUEST_METHOD'} eq "GET")
{
    $values = $ENV{'QUERY_STRING'};
}
elsif ($ENV{'REQUEST_METHOD'} eq "POST")
{
    my $old = $/;
    $/ = undef;
    $values = <STDIN>;
    $/ = $old;
}
My Perl is a bit rusty, but this is the general idea of how to do it. Just parse the values variable after that piece of code, and you should get the values you want. //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top