dougm       01/05/07 21:25:51

  Modified:    lib/Apache compat.pm
               lib/ModPerl Code.pm
               src/modules/perl mod_perl.c mod_perl.h
               t/response/TestApache cgihandler.pm
  Added:       t/modules cgi.t
               t/response/TestModules cgi.pm
  Log:
  integrate with modperl_env module and get some basic CGI.pm tests in place
  
  Revision  Changes    Path
  1.9       +6 -12     modperl-2.0/lib/Apache/compat.pm
  
  Index: compat.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- compat.pm 2001/05/04 19:46:26     1.8
  +++ compat.pm 2001/05/08 04:25:47     1.9
  @@ -23,6 +23,7 @@
   use Apache::RequestIO ();
   use Apache::RequestUtil ();
   use APR::Table ();
  +use APR::Pool ();
   use mod_perl ();
   
   BEGIN {
  @@ -31,6 +32,7 @@
       $INC{'Apache/Constants.pm'} = 1;
   
       $ENV{MOD_PERL} = $mod_perl::VERSION;
  +    $ENV{GATEWAY_INTERFACE} = 'CGI-Perl/1.1';
   }
   
   package Apache;
  @@ -54,6 +56,10 @@
   
   package Apache::RequestRec;
   
  +sub register_cleanup {
  +    shift->pool->cleanup_register(@_);
  +}
  +
   sub parse_args {
       my($r, $string) = @_;
       return () unless defined $string and $string;
  @@ -88,18 +94,6 @@
   
       return $buf unless wantarray;
       return $r->parse_args($buf)
  -}
  -
  -our $Request;
  -
  -sub request {
  -    my($r, $set) = @_;
  -    $Request = $set if $set;
  -
  -    untie *STDOUT;
  -    tie *STDOUT, 'Apache::RequestRec', $r;
  -
  -    $Request;
   }
   
   sub send_http_header {
  
  
  
  1.63      +1 -1      modperl-2.0/lib/ModPerl/Code.pm
  
  Index: Code.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/lib/ModPerl/Code.pm,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- Code.pm   2001/05/05 22:08:44     1.62
  +++ Code.pm   2001/05/08 04:25:48     1.63
  @@ -522,7 +522,7 @@
   );
   
   my @c_src_names = qw(interp tipool log config cmd options callback handler
  -                     gtop util io filter bucket mgv pcw global);
  +                     gtop util io filter bucket mgv pcw global env);
   my @g_c_names = map { "modperl_$_" } qw(hooks directives flags xsinit);
   my @c_names   = ('mod_perl', (map "modperl_$_", @c_src_names));
   sub c_files { [map { "$_.c" } @c_names, @g_c_names] }
  
  
  
  1.55      +3 -0      modperl-2.0/src/modules/perl/mod_perl.c
  
  Index: mod_perl.c
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- mod_perl.c        2001/05/05 22:08:44     1.54
  +++ mod_perl.c        2001/05/08 04:25:49     1.55
  @@ -409,10 +409,13 @@
       h_stdout = modperl_io_tie_stdout(aTHX_ r);
       h_stdin  = modperl_io_tie_stdin(aTHX_ r);
   
  +    modperl_env_request_tie(aTHX_ r);
       retval = modperl_response_handler_run(r);
   
       modperl_io_handle_untie(aTHX_ h_stdout);
       modperl_io_handle_untie(aTHX_ h_stdin);
  +
  +    modperl_env_request_untie(aTHX_ r);
   
       return retval;
   }
  
  
  
  1.33      +1 -0      modperl-2.0/src/modules/perl/mod_perl.h
  
  Index: mod_perl.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.h,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- mod_perl.h        2001/05/05 22:08:44     1.32
  +++ mod_perl.h        2001/05/08 04:25:49     1.33
  @@ -31,6 +31,7 @@
   #include "modperl_pcw.h"
   #include "modperl_mgv.h"
   #include "modperl_global.h"
  +#include "modperl_env.h"
   
   void modperl_init(server_rec *s, apr_pool_t *p);
   void modperl_hook_init(apr_pool_t *pconf, apr_pool_t *plog, 
  
  
  
  1.1                  modperl-2.0/t/modules/cgi.t
  
  Index: cgi.t
  ===================================================================
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::Test;
  use Apache::TestRequest;
  
  plan tests => 3, \&have_lwp;
  
  my $location = "/TestModules::cgi";
  
  ok 1;
  
  my $str = GET_BODY "$location?PARAM=2";
  print $str;
  
  $str = POST_BODY $location, content => 'PARAM=%33';
  print $str;
  
  
  
  1.2       +6 -3      modperl-2.0/t/response/TestApache/cgihandler.pm
  
  Index: cgihandler.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/response/TestApache/cgihandler.pm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- cgihandler.pm     2001/05/05 22:08:45     1.1
  +++ cgihandler.pm     2001/05/08 04:25:50     1.2
  @@ -9,8 +9,9 @@
   
   sub handler {
       my $r = shift;
  -    $r->content_type('text/plain');
   
  +    $ENV{FOO} = 2;
  +
       if ($r->method_number == Apache::M_POST) {
           my $ct = $r->headers_in->get('content-length');
           my $buff;
  @@ -19,8 +20,10 @@
       }
       else {
           print "1..3\n";
  -        print "ok 1\n", "ok ", "2\n";
  -        print "ok 3\n";
  +        print "ok 1\n", "ok ", "$ENV{FOO}\n";
  +        my $foo = $r->subprocess_env->get('FOO');
  +        $foo++;
  +        print "ok $foo\n";
       }
   
       Apache::OK;
  
  
  
  1.1                  modperl-2.0/t/response/TestModules/cgi.pm
  
  Index: cgi.pm
  ===================================================================
  package TestModules::cgi;
  
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::compat ();
  use CGI ();
  
  sub handler {
      my $r = shift;
  
      my $cgi = CGI->new;
  
      my $param = $cgi->param('PARAM');
      my $httpupload = $cgi->param('HTTPUPLOAD');
  
  #    $cgi->print( $cgi->header(-type => "text/plain",
  #                              "-X-Perl-Script" => "cgi.pl") );
  
      print "ok $param\n" if $param;
  
      if ($httpupload) {
          no strict;
          local $/;
          my $content = <$httpupload>;
          print "ok $content\n";
      }
  
      Apache::OK;
  }
  
  1;
  __END__
  SetHandler perl-script
  PerlOptions +GlobalRequest
  
  
  

Reply via email to