You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by st...@apache.org on 2003/01/12 05:00:42 UTC
cvs commit: modperl-2.0/t/filter/TestFilter buckets.pm
stas 2003/01/11 20:00:42
Modified: t/filter/TestFilter buckets.pm
Log:
make sure that the body of the filter is executed only once
Revision Changes Path
1.8 +22 -17 modperl-2.0/t/filter/TestFilter/buckets.pm
Index: buckets.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/filter/TestFilter/buckets.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- buckets.pm 11 Sep 2002 00:50:31 -0000 1.7
+++ buckets.pm 12 Jan 2003 04:00:42 -0000 1.8
@@ -19,31 +19,36 @@
sub handler {
my($filter, $bb) = @_;
- Apache::TestToString->start;
+ unless ($filter->ctx) {
- plan tests => 4;
+ Apache::TestToString->start;
- my $ba = $filter->r->connection->bucket_alloc;
+ plan tests => 4;
- #should only have 1 bucket from the response() below
- for (my $bucket = $bb->first; $bucket; $bucket = $bb->next($bucket)) {
- ok $bucket->type->name;
- ok $bucket->length == 2;
- $bucket->read(my $data);
- ok $data eq 'ok';
- }
+ my $ba = $filter->r->connection->bucket_alloc;
+
+ #should only have 1 bucket from the response() below
+ for (my $bucket = $bb->first; $bucket; $bucket = $bb->next($bucket)) {
+ ok $bucket->type->name;
+ ok $bucket->length == 2;
+ $bucket->read(my $data);
+ ok (defined $data and $data eq 'ok');
+ }
- my $tests = Apache::TestToString->finish;
+ my $tests = Apache::TestToString->finish;
- my $brigade = APR::Brigade->new($filter->r->pool, $ba);
- my $bucket = APR::Bucket->new($tests);
+ my $brigade = APR::Brigade->new($filter->r->pool, $ba);
+ my $bucket = APR::Bucket->new($tests);
- $brigade->insert_tail($bucket);
+ $brigade->insert_tail($bucket);
- my $ok = $brigade->first->type->name =~ /mod_perl/ ? 4 : 0;
- $brigade->insert_tail(APR::Bucket->new("ok $ok\n"));
+ my $ok = $brigade->first->type->name =~ /mod_perl/ ? 4 : 0;
+ $brigade->insert_tail(APR::Bucket->new("ok $ok\n"));
- $filter->next->pass_brigade($brigade);
+ $filter->next->pass_brigade($brigade);
+
+ $filter->ctx(1); # flag that we have run this already
+ }
Apache::OK;
}