hi all...

this patch contains only the tests for subrequests used in filters. you can use it to test or reproduce the problem.

craig - in case it got lost in the mass of email yesterday, if you could try the latest cvs version of mod_perl and see if it core dumps, that would be great. reporting the result of your standalone test as well as these new tests is also appreciated.

--Geoff
--- /dev/null   2003-01-30 05:24:37.000000000 -0500
+++ t/filter/TestFilter/out_str_subreq_default.pm       2003-08-27 08:27:41.000000000 
-0400
@@ -0,0 +1,78 @@
+package TestFilter::out_str_subreq_default;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+
+use Apache::RequestRec ();
+use Apache::RequestIO ();
+use Apache::SubRequest ();
+
+use Apache::Filter ();
+
+use Apache::Const -compile => qw(OK);
+
+# include the contents of a subrequest
+# in the filter, a la mod_include's 
+# <!--#include virtual="/subrequest" -->
+
+sub include {
+
+    my $filter = shift;
+
+    unless ($filter->ctx) {
+        # don't forget to remove the C-L header
+        $filter->r->headers_out->unset('Content-Length');
+
+        $filter->ctx(1);
+    }
+
+    while ($filter->read(my $buffer, 1024)){
+
+        if ($buffer eq "<tag>\n") {
+            my $sub = $filter->r->lookup_uri('/default_subrequest/subrequest.txt');
+            my $rc = $sub->run;
+        }
+        else {
+           # send all other data along unaltered
+           $filter->print($buffer);
+        }
+
+    }
+
+    # add our own at the end
+    if ($filter->seen_eos) {
+        $filter->print("filter\n");
+        $filter->ctx(1);
+    }
+
+    return Apache::OK;
+}
+
+sub response {
+
+    my $r = shift;
+
+    $r->content_type('text/plain');
+
+    $r->print("content\n");
+    $r->rflush;
+    $r->print("<tag>\n");
+    $r->rflush;
+    $r->print("more content\n");
+
+    Apache::OK;
+}
+1;
+__DATA__
+SetHandler modperl
+PerlModule              TestFilter::out_str_subreq_default
+PerlResponseHandler     TestFilter::out_str_subreq_default::response
+PerlOutputFilterHandler TestFilter::out_str_subreq_default::include
+
+Alias /default_subrequest @DocumentRoot@/filter
+<Location /default_subrequest>
+  SetHandler default-handler
+</Location>

--- /dev/null   2003-01-30 05:24:37.000000000 -0500
+++ t/filter/TestFilter/out_str_subreq_modperl.pm       2003-08-27 08:28:01.000000000 
-0400
@@ -0,0 +1,88 @@
+package TestFilter::out_str_subreq_modperl;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+
+use Apache::RequestRec ();
+use Apache::RequestIO ();
+use Apache::SubRequest ();
+
+use Apache::Filter ();
+
+use Apache::Const -compile => qw(OK);
+
+# include the contents of a subrequest
+# in the filter, a la mod_include's 
+# <!--#include virtual="/subrequest" -->
+
+sub include {
+
+    my $filter = shift;
+
+    unless ($filter->ctx) {
+        # don't forget to remove the C-L header
+        $filter->r->headers_out->unset('Content-Length');
+
+        $filter->ctx(1);
+    }
+
+    while ($filter->read(my $buffer, 1024)){
+
+        if ($buffer eq "<tag>\n") {
+            my $sub = $filter->r->lookup_uri('/modperl_subrequest');
+            my $rc = $sub->run;
+        }
+        else {
+           # send all other data along unaltered
+           $filter->print($buffer);
+        }
+
+    }
+
+    # add our own at the end
+    if ($filter->seen_eos) {
+        $filter->print("filter\n");
+        $filter->ctx(1);
+    }
+
+    return Apache::OK;
+}
+
+sub subrequest {
+
+    my $r = shift;
+
+    $r->content_type('text/plain');
+    $r->print("modperl subrequest\n");
+
+    return Apache::OK;
+}
+
+sub response {
+
+    my $r = shift;
+
+    $r->content_type('text/plain');
+
+    $r->print("content\n");
+    $r->rflush;
+    $r->print("<tag>\n");
+    $r->rflush;
+    $r->print("more content\n");
+
+    Apache::OK;
+}
+1;
+__DATA__
+SetHandler modperl
+PerlModule              TestFilter::out_str_subreq_modperl
+PerlResponseHandler     TestFilter::out_str_subreq_modperl::response
+PerlOutputFilterHandler TestFilter::out_str_subreq_modperl::include
+
+<Location /modperl_subrequest>
+  SetHandler modperl
+  PerlResponseHandler   TestFilter::out_str_subreq_modperl::subrequest
+</Location>

--- /dev/null   2003-01-30 05:24:37.000000000 -0500
+++ t/filter/out_str_subreq_default.t   2003-08-27 08:18:46.000000000 -0400
@@ -0,0 +1,21 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest;
+use Apache::TestUtil;
+
+plan tests => 1;
+
+my $location = '/TestFilter__out_str_subreq_default';
+
+my $content1    = "content\n";
+my $content2    = "more content\n";
+my $filter      = "filter\n";
+my $subrequest  = "default-handler subrequest\n";
+
+my $expected = join '', $content1, $subrequest, $content2, $filter;
+my $received = GET_BODY $location;
+
+ok t_cmp($expected, $received, 
+    "testing filter-originated lookup_uri() call to core served URI");

--- /dev/null   2003-01-30 05:24:37.000000000 -0500
+++ t/filter/out_str_subreq_modperl.t   2003-08-27 08:18:42.000000000 -0400
@@ -0,0 +1,21 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest;
+use Apache::TestUtil;
+
+plan tests => 1;
+
+my $location = '/TestFilter__out_str_subreq_modperl';
+
+my $content1    = "content\n";
+my $content2    = "more content\n";
+my $filter      = "filter\n";
+my $subrequest  = "modperl subrequest\n";
+
+my $expected = join '', $content1, $subrequest, $content2, $filter;
+my $received = GET_BODY $location;
+
+ok t_cmp($expected, $received, 
+    "testing filter-originated lookup_uri() call to modperl-served URI");

--- /dev/null   2003-01-30 05:24:37.000000000 -0500
+++ t/htdocs/filter/subrequest.txt      2003-08-27 08:18:13.000000000 -0400
@@ -0,0 +1 @@
+default-handler subrequest

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to