perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject cvs commit: modperl-2.0/t/response/TestModules cgipost.pm
Date Fri, 07 Nov 2003 08:51:57 GMT
stas        2003/11/07 00:51:57

  Added:       t/modules cgipost.t
               t/response/TestModules cgipost.pm
  Log:
  - a new cgipost test (testing non-multipart POST via CGI.pm)
  Submitted by:	Geoffrey Young
  
  Revision  Changes    Path
  1.1                  modperl-2.0/t/modules/cgipost.t
  
  Index: cgipost.t
  ===================================================================
  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);
  }
  
  
  
  
  1.1                  modperl-2.0/t/response/TestModules/cgipost.pm
  
  Index: cgipost.pm
  ===================================================================
  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
  
  
  

Mime
View raw message