Geoffrey Young wrote:
hi all

attached is a test that uses CGI.pm to parse large chunks of POST data. currently, it fails for me in tests 3-6, which corresponds to a recent discussion on modperl@ where a user was seeing only part of his POST data for largish chunks.

granted, after discussing with stas, the problem isn't really due to CGI.pm, so the test is excercising mod_perl internals rather than CGI.pm. however, the test is probably similar to one a user would have sent, and it we had had the test we wouldn't have gotten the bug report :) and, since we have redirect and cookie tests in the Registry suite, it can't hurt to have this one as well - more tests == good software :)

I don't want to commit it, though, until the underlying problem is fixed, so it's really just FYI at this point.

Thanks Geoff! This test is indeed was missing, since cgiupload tested multipart POST, but not a plain POST. Now if you don't mind I've moved your proposed test to where all the CGI.pm tests are. There really no need to run it off registry.


Also I've s/BODY/BODY_ASSERT/ since if something fails it'll return an error response body, which is normally OK if you compare the string, but since the debug line was printing the length of the response it was misleading. Also changed s/print STDERR/t_debug/ which does it consistently with other debug prints (starting with leading # ). Finally removed the hardcoded number of tests.

I've posted a patch to CGI.pm that makes this test pass.

--- /dev/null   1969-12-31 16:00:00.000000000 -0800
+++ t/modules/cgipost.t 2003-10-31 13:26:22.000000000 -0800
@@ -0,0 +1,36 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+use Apache::TestRequest qw(POST_BODY_ASSERT);
+
+my $module = 'TestModules::cgipost';
+my $url = '/' . Apache::TestRequest::module2path($module);
+
+my @data = (25, 50, 75, 100, 125, 150);
+
+plan tests => scalar(@data), have_min_module_version(CGI => 2.93);
+
+foreach my $post (@data) {
+    my %param = ();
+
+    foreach my $key (1 .. $post) {
+      $param{$key} = 'data' x $key;
+    }
+
+    my $post_data = join '&', map { "$_=$param{$_}" }
+                              sort { $a <=> $b } keys %param;
+    my $expected  = join ':', map { $param{$_}      }
+                              sort { $a <=> $b } keys %param;
+
+    my $e_length = length $expected;
+
+    my $received = POST_BODY_ASSERT $url, content => $post_data;
+
+    my $r_length = length $received;
+
+    t_debug "expected $e_length bytes, received $r_length bytes\n";
+    ok ($expected eq $received);
+}
+

--- /dev/null   1969-12-31 16:00:00.000000000 -0800
+++ t/response/TestModules/cgipost.pm   2003-10-31 13:25:51.000000000 -0800
@@ -0,0 +1,25 @@
+package TestModules::cgipost;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::compat ();
+use CGI ();
+
+use Apache::Const -compile => 'OK';
+
+sub handler {
+    my $r = shift;
+
+    $r->content_type('text/plain');
+    my $cgi = CGI->new;
+
+    print join ":", map { $cgi->param($_) } $cgi->param;
+
+    Apache::OK;
+}
+
+1;
+__END__
+SetHandler perl-script
+PerlOptions +GlobalRequest


__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to