bogocles
10-19-2007, 03:47 PM
I've been toying around with a test script that prints environment variables and provides two forms, each with either a post or get method. I've noticed that when I supply the same text in both the POST and the GET form, the GET form seems to take precedence as the associated environment variables get GET properties only. Most notably:
REQUEST_METHOD = GET
... and CONTENT_LENGTH isn't set.
The only way to get REQUEST_METHOD = POST is to submit a method="post" form without any GET information in the url.
This seems kinda like a drawback. I'm trying to port over a php application that I've developed but it sends information via POST and GET, which doesn't appear to work in PERL. It looks like you get either or.
Is this right? If it is, are there any work-arounds? Porting is headache enough without have to make major structural changes to the code :(
The test script I'm using is a slightly modified version of one from /www.gossland.com/. Here's the code if anyone wants to mess around with it:
#!/usr/bin/perl -w
use CGI::Carp qw ( warningsToBrowser fatalsToBrowser );
print "Content-type: text/html\n\n";
print qq{<html><head></head><body>};
#print every key in the environment
foreach $key ( sort ( keys %ENV ) ) {
print $key, ' = ', $ENV { $key }, "<br />\n";
}
#print a couple of simple forms: a POST form and a GET form
print qq {
<form method="POST" ><input type="submit" value="Post Request"><input name="postfield"></form>
};
print qq {
<form method="GET" ><input type="submit" value="Get Request "><input name="getfield"></form>
};
print qq {
</body></html>
};
REQUEST_METHOD = GET
... and CONTENT_LENGTH isn't set.
The only way to get REQUEST_METHOD = POST is to submit a method="post" form without any GET information in the url.
This seems kinda like a drawback. I'm trying to port over a php application that I've developed but it sends information via POST and GET, which doesn't appear to work in PERL. It looks like you get either or.
Is this right? If it is, are there any work-arounds? Porting is headache enough without have to make major structural changes to the code :(
The test script I'm using is a slightly modified version of one from /www.gossland.com/. Here's the code if anyone wants to mess around with it:
#!/usr/bin/perl -w
use CGI::Carp qw ( warningsToBrowser fatalsToBrowser );
print "Content-type: text/html\n\n";
print qq{<html><head></head><body>};
#print every key in the environment
foreach $key ( sort ( keys %ENV ) ) {
print $key, ' = ', $ENV { $key }, "<br />\n";
}
#print a couple of simple forms: a POST form and a GET form
print qq {
<form method="POST" ><input type="submit" value="Post Request"><input name="postfield"></form>
};
print qq {
<form method="GET" ><input type="submit" value="Get Request "><input name="getfield"></form>
};
print qq {
</body></html>
};