cvs commit: modperl-2.0/t/filter/TestFilter input_msg.pm

2001-11-05 Thread dougm

dougm   01/11/05 16:08:46

  Modified:t/filter/TestFilter input_msg.pm
  Log:
  change filter logic to what is currently considered the "right way"
  
  Revision  ChangesPath
  1.7   +21 -11modperl-2.0/t/filter/TestFilter/input_msg.pm
  
  Index: input_msg.pm
  ===
  RCS file: /home/cvs/modperl-2.0/t/filter/TestFilter/input_msg.pm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- input_msg.pm  2001/07/15 22:33:49 1.6
  +++ input_msg.pm  2001/11/06 00:08:46 1.7
  @@ -16,26 +16,36 @@
   sub handler : FilterConnectionHandler {
   my($filter, $bb, $mode, $readbytes) = @_;
   
  -if ($bb->empty) {
  -my $rv = $filter->next->get_brigade($bb, $mode, $readbytes);
  +my $ctx_bb = APR::Brigade->new($filter->c->pool);
   
  -if ($rv != APR::SUCCESS) {
  -return $rv;
  -}
  +my $rv = $filter->next->get_brigade($ctx_bb, $mode, $readbytes);
  +
  +if ($rv != APR::SUCCESS) {
  +return $rv;
   }
   
  -for (my $bucket = $bb->first; $bucket; $bucket = $bb->next($bucket)) {
  +while (!$ctx_bb->empty) {
   my $data;
  -my $status = $bucket->read($data);
  +my $bucket = $ctx_bb->first;
   
   $bucket->remove;
   
  -if ($data and $data =~ s,GET $from_url,GET $to_url,) {
  -$bb->insert_tail(APR::Bucket->new($data));
  -}
  -else {
  +if ($bucket->is_eos) {
   $bb->insert_tail($bucket);
  +last;
   }
  +
  +my $status = $bucket->read($data);
  +
  +if ($status != APR::SUCCESS) {
  +return $status;
  +}
  +
  +if ($data and $data =~ s,GET $from_url,GET $to_url,) {
  +$bucket = APR::Bucket->new($data);
  +}
  +
  +$bb->insert_tail($bucket);
   }
   
   Apache::OK;
  
  
  



cvs commit: modperl-2.0/t/filter/TestFilter input_msg.pm

2001-04-24 Thread dougm

dougm   01/04/24 19:02:20

  Modified:Apache-Test/lib/Apache TestConfigPerl.pm
   t/filter/TestFilter input_msg.pm
  Log:
  seems that Perls < bleedperl leak __DATA__ filehandles
  this causes a core dump if a .pm containing __DATA__ is loaded at startup
  bandaid by using __END__ instead
  
  Revision  ChangesPath
  1.10  +1 -1  modperl-2.0/Apache-Test/lib/Apache/TestConfigPerl.pm
  
  Index: TestConfigPerl.pm
  ===
  RCS file: /home/cvs/modperl-2.0/Apache-Test/lib/Apache/TestConfigPerl.pm,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TestConfigPerl.pm 2001/04/19 21:21:17 1.9
  +++ TestConfigPerl.pm 2001/04/25 02:02:19 1.10
  @@ -173,7 +173,7 @@
   open(my $fh, $module) or return;
   
   while (<$fh>) {
  -last if /^__DATA__/;
  +last if /^__(DATA|END)__/;
   }
   
   while (<$fh>) {
  
  
  
  1.5   +1 -1  modperl-2.0/t/filter/TestFilter/input_msg.pm
  
  Index: input_msg.pm
  ===
  RCS file: /home/cvs/modperl-2.0/t/filter/TestFilter/input_msg.pm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- input_msg.pm  2001/04/24 02:26:17 1.4
  +++ input_msg.pm  2001/04/25 02:02:19 1.5
  @@ -52,7 +52,7 @@
   }
   
   1;
  -__DATA__
  +__END__
   
   
 PerlInputFilterHandler TestFilter::input_msg
  
  
  



cvs commit: modperl-2.0/t/filter/TestFilter input_msg.pm

2001-04-19 Thread dougm

dougm   01/04/19 14:28:04

  Added:   t/filter input_msg.t
   t/filter/TestFilter input_msg.pm
  Log:
  add test for InputFilterMessage handler
  
  Revision  ChangesPath
  1.1  modperl-2.0/t/filter/input_msg.t
  
  Index: input_msg.t
  ===
  use Apache::TestRequest ();
  use Apache::TestConfig ();
  
  my $module = 'TestFilter::input_msg';
  
  local $Apache::TestRequest::Module = $module;
  $Apache::TestRequest::Module ||= $module; #-w
  
  my $config = Apache::TestConfig->thaw;
  my $hostport = Apache::TestRequest::hostport($config);
  print "connecting to $hostport\n";
  
  print $config->http_raw_get("/input_filter.html");
  
  
  
  1.1  modperl-2.0/t/filter/TestFilter/input_msg.pm
  
  Index: input_msg.pm
  ===
  package TestFilter::input_msg;
  
  use strict;
  use warnings FATAL => 'all';
  
  use base qw(Apache::Filter);
  
  use Test;
  use Apache::Test ();
  use APR::Brigade ();
  use APR::Bucket ();
  
  #XXX
  @Apache::InputFilter::ISA = qw(Apache::OutputFilter);
  
  my $from_url = '/input_filter.html';
  my $to_url = '/TestFilter::input_msg::response';
  
  sub handler : InputFilterMessage {
  my($filter, $bb, $mode) = @_;
  
  if ($bb->empty) {
  my $rv = $filter->f->next->get_brigade($bb, $mode);
  
  if ($rv != APR::SUCCESS) {
  return $rv;
  }
  }
  
  for (my $bucket = $bb->first; $bucket; $bucket = $bb->next($bucket)) {
  my $data;
  my $status = $bucket->read($data);
  
  $bucket->remove;
  
  if ($data and $data =~ s,GET $from_url,GET $to_url,) {
  $bb->insert_tail(APR::Bucket->new($data));
  }
  else {
  $bb->insert_tail($bucket);
  }
  }
  
  Apache::OK;
  }
  
  sub response {
  my $r = shift;
  
  $r->content_type('text/plain');
  
  $r->puts("1..1\nok 1\n");
  
  Apache::OK;
  }
  
  1;
  __DATA__
  
  
PerlInputFilterHandler TestFilter::input_msg
  

   SetHandler modperl
   PerlResponseHandler TestFilter::input_msg::response