I am trying to provide a simulation on Web request, GET and POST, during my shell development, coz I don't want to implement a batch form query combination and see the results via my browser. This is very inefficient if I use my browser to fill in the blanks, change something and submit again time to time.
My simulation module is simply to set $ENV{REQUEST_METHOD} = "GET" and then $ENV{QUERY_STRING} = "Var1=Val1&Var2=Val2" (when I run the code in shell)
Now the GET request is done, but the POST request won't work as it read (STDIN, my $buf, 4096) and I can't find anyway to feed the STDIN
My recent shortcoming approach it to alter a POST request to GET and URI encode the data string, it works on some cases, however it won't pass through when somecgi.pl performs :
if ( $ENV{REQUEST_METHOD} eq "GET" ) {
print_the_form();
}
elsif ( $ENV{REQUEST_METHOD} eq "POST" ) {
handle_the_form();
}
else { print "GET and POST request only" }
Any clues for this ? Thanks a lot!