stas2002/11/25 14:46:29
Modified:t/filter .cvsignore
src/modules/perl modperl_filter.c modperl_types.h
t/filter/TestFilter reverse.pm
.Changes
Added: t/htdocs/filter reverse.txt
t/filter reverse.t
Log:
Allow output streaming filters to append data to the end of the stream, by
postponing the propogation of the EOS bucket down the stream till the
handler is returned. + tests
Revision ChangesPath
1.1 modperl-2.0/t/htdocs/filter/reverse.txt
Index: reverse.txt
===
zyxwvutsrqponmlkjihgfedcba
9876543210
1.3 +1 -1 modperl-2.0/t/filter/.cvsignore
Index: .cvsignore
===
RCS file: /home/cvs/modperl-2.0/t/filter/.cvsignore,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- .cvsignore12 Sep 2001 17:11:48 - 1.2
+++ .cvsignore25 Nov 2002 22:46:29 - 1.3
@@ -3,4 +3,4 @@
input_body.t
input_msg.t
lc.t
-reverse.t
+
1.3 +28 -3 modperl-2.0/t/filter/reverse.t
1.39 +14 -2 modperl-2.0/src/modules/perl/modperl_filter.c
Index: modperl_filter.c
===
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- modperl_filter.c 19 Aug 2002 20:07:01 - 1.38
+++ modperl_filter.c 25 Nov 2002 22:46:29 - 1.39
@@ -157,6 +157,17 @@
MP_TRACE_f(MP_FUNC, "%s returned %d\n", handler->name, status);
+/* when the streaming filter is invoked it should be able to send
+ * extra data, after the read in a while() loop is finished.
+ * Therefore we need to postpone propogating the EOS bucket, up
+ * until the filter handler is returned and only then send the EOS
+ * bucket if the stream had one.
+ */
+if (filter->seen_eos) {
+filter->eos = 1;
+filter->seen_eos = 0;
+}
+
if (filter->mode == MP_OUTPUT_FILTER_MODE) {
modperl_output_filter_flush(filter);
}
@@ -213,7 +224,8 @@
return 1;
}
else if (MP_FILTER_IS_EOS(filter)) {
-filter->eos = 1;
+MP_TRACE_f(MP_FUNC, "received EOS bucket\n");
+filter->seen_eos = 1;
return 1;
}
else if (filter->bucket != MP_FILTER_SENTINEL(filter)) {
@@ -281,7 +293,7 @@
if (MP_FILTER_IS_EOS(filter)) {
MP_TRACE_f(MP_FUNC, "received EOS bucket\n");
-filter->eos = 1;
+filter->seen_eos = 1;
break;
}
else if (MP_FILTER_IS_FLUSH(filter)) {
1.63 +1 -0 modperl-2.0/src/modules/perl/modperl_types.h
Index: modperl_types.h
===
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_types.h,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- modperl_types.h 15 Sep 2002 23:30:06 - 1.62
+++ modperl_types.h 25 Nov 2002 22:46:29 - 1.63
@@ -184,6 +184,7 @@
} modperl_filter_mode_e;
typedef struct {
+int seen_eos;
int eos;
int flush;
ap_filter_t *f;
1.4 +16 -5 modperl-2.0/t/filter/TestFilter/reverse.pm
Index: reverse.pm
===
RCS file: /home/cvs/modperl-2.0/t/filter/TestFilter/reverse.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- reverse.pm11 Apr 2002 11:08:43 - 1.3
+++ reverse.pm25 Nov 2002 22:46:29 - 1.4
@@ -7,7 +7,7 @@
use Apache::RequestIO ();
use Apache::Filter ();
-use Apache::Const -compile => 'OK';
+use Apache::Const -compile => qw(OK M_POST);
sub handler {
my $filter = shift;
@@ -18,21 +18,32 @@
$filter->print("\n");
}
}
+$filter->print("Reversed by mod_perl 2.0\n");
-0;
+return Apache::OK;
}
sub response {
my $r = shift;
$r->content_type('text/plain');
-$r->puts(scalar reverse "1..1\n");
-$r->puts(scalar reverse "ok 1\n");
-Apache::OK;
+if ($r->method_number == Apache::M_POST) {
+my $data = ModPerl::Test::read_post($r);
+$r->puts($data);
+}
+
+return Apache::OK;
}
1;
__DATA__
+
+
+PerlOutputFilterHandler TestFilter::reverse
+
+
+
SetHandler modperl
PerlResponseHandler TestFilter::reverse::response
+
1.63 +3 -0 modperl-2.0/Changes
Index: Changes
=