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 2004/01/20 02:26:35 UTC
cvs commit: modperl-2.0/t/conf modperl_extra.pl
stas 2004/01/19 17:26:34
Modified: t/conf modperl_extra.pl
Added: t/filter in_autoload.t
t/filter/TestFilter in_autoload.pm
Log:
test that PerlInputFilterHandler autoloads the module containing the
handler (since it's ::handler and not a custom sub name we don't have to
explicitly call PerlModule)
add a new helper response handler
ModPerl::Test::pass_through_response_handler preloaded at the server
startup.
no point testing PerlOutputFilterHandler as it does the same
Revision Changes Path
1.1 modperl-2.0/t/filter/in_autoload.t
Index: in_autoload.t
===================================================================
use strict;
use warnings FATAL => 'all';
use Apache::Test;
use Apache::TestUtil;
use Apache::TestRequest;
plan tests => 1;
my $location = '/TestFilter__in_autoload';
my $data = "[Foo BaR] ";
my $expected = lc $data;
my $received = POST_BODY $location, content => $data;
ok t_cmp($expected, $received, "input stream filter lc autoloaded")
1.1 modperl-2.0/t/filter/TestFilter/in_autoload.pm
Index: in_autoload.pm
===================================================================
package TestFilter::in_autoload;
# test that PerlInputFilterHandler autoloads the module containing the
# handler (since it's ::handler and not a custom sub name we don't
# have to explicitly call PerlModule)
#
# no point testing PerlOutputFilterHandler as it does the same
use strict;
use warnings FATAL => 'all';
use Apache::Filter ();
use Apache::TestTrace;
use Apache::Const -compile => qw(OK);
sub handler {
my $filter = shift;
while ($filter->read(my $buffer, 1024)) {
debug "filter read: $buffer";
$filter->print(lc $buffer);
}
return Apache::OK;
}
1;
__DATA__
<NoAutoConfig>
<Location /TestFilter__in_autoload>
SetHandler modperl
PerlResponseHandler ModPerl::Test::pass_through_response_handler
# no PerlModule TestFilter::in_load on purpose
PerlInputFilterHandler TestFilter::in_autoload
</Location>
</NoAutoConfig>
1.38 +15 -0 modperl-2.0/t/conf/modperl_extra.pl
Index: modperl_extra.pl
===================================================================
RCS file: /home/cvs/modperl-2.0/t/conf/modperl_extra.pl,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -u -r1.37 -r1.38
--- modperl_extra.pl 19 Jan 2004 19:59:58 -0000 1.37
+++ modperl_extra.pl 20 Jan 2004 01:26:34 -0000 1.38
@@ -103,6 +103,21 @@
eval { require threads; "threads"->import() };
}
+use Apache::TestTrace;
+use Apache::Const -compile => qw(M_POST);
+
+# read the posted body and send it back to the client as is
+sub ModPerl::Test::pass_through_response_handler {
+ my $r = shift;
+
+ if ($r->method_number == Apache::M_POST) {
+ my $data = ModPerl::Test::read_post($r);
+ debug "pass_through_handler read: $data\n";
+ $r->print($data);
+ }
+
+ Apache::OK;
+}
use constant IOBUFSIZE => 8192;