stas        2003/08/26 16:28:04

  Modified:    lib/ModPerl TestRun.pm
  Added:       t/modules proxy.t
               t/response/TestModules proxy.pm
  Log:
  new test: converting a normal request to a proxy request
  - requires to bump up the number of maxclients to 2
  
  Revision  Changes    Path
  1.11      +7 -0      modperl-2.0/lib/ModPerl/TestRun.pm
  
  Index: TestRun.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/lib/ModPerl/TestRun.pm,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TestRun.pm        26 Aug 2003 22:19:19 -0000      1.10
  +++ TestRun.pm        26 Aug 2003 23:28:04 -0000      1.11
  @@ -5,8 +5,15 @@
   
   use base qw(Apache::TestRunPerl);
   
  +# some mp2 tests require more than one server instance to be available
  +# without which the server may hang, waiting for the single server
  +# become available
  +use constant MIN_MAXCLIENTS => 2;
  +
   sub new_test_config {
       my $self = shift;
  +
  +    $self->{conf_opts}->{maxclients} = MIN_MAXCLIENTS;
   
       ModPerl::TestConfig->new($self->{conf_opts});
   }
  
  
  
  1.1                  modperl-2.0/t/modules/proxy.t
  
  Index: proxy.t
  ===================================================================
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::Test;
  use Apache::TestUtil;
  
  use Apache::TestRequest;
  
  my $location = "/TestModules__proxy";
  
  plan tests => 1, [qw(proxy access)];
  
  my $expected = "ok";
  my $received = GET_BODY_ASSERT $location;
  ok t_cmp($expected, $received, "internally proxified request");
  
  
  
  1.1                  modperl-2.0/t/response/TestModules/proxy.pm
  
  Index: proxy.pm
  ===================================================================
  package TestModules::proxy;
  
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::Test;
  
  use Apache::Server ();
  use Apache::RequestRec ();
  use Apache::RequestIO ();
  
  my $uri_real = "/TestModules__proxy_real";
  
  use Apache::Const -compile => qw(DECLINED OK);
  
  sub proxy {
      my $r = shift;
  
      return Apache::DECLINED if $r->proxyreq;
      return Apache::DECLINED unless $r->uri eq '/TestModules__proxy';
  
      my $s = $r->server;
      my $real_url = sprintf "http://%s:%d%s";,
          $s->server_hostname, $s->port, $uri_real;
  
      $r->proxyreq(1);
      $r->uri($real_url);
      $r->filename("proxy:$real_url");
      $r->handler('proxy-server');
  
      return Apache::OK;
  }
  
  sub response {
      my $r = shift;
  
      $r->content_type('text/plain');
      $r->print("ok");
  
      return Apache::OK;
  }
  
  1;
  __END__
  <NoAutoConfig>
      <IfModule mod_proxy.c>
      <IfModule mod_access.c>
          <Proxy http://@servername@:@port@/*>
              Order Deny,Allow
              Deny from all
              Allow from @servername@
          </Proxy>
          ProxyRequests On
  
          PerlModule TestModules::proxy
          PerlTransHandler TestModules::proxy::proxy
          <Location /TestModules__proxy_real>
              SetHandler modperl
              PerlResponseHandler TestModules::proxy::response
          </Location>
      </IfModule>
      </IfModule>
  </NoAutoConfig>
  
  
  
  

Reply via email to