Return-Path: Delivered-To: apmail-perl-dev-archive@perl.apache.org Received: (qmail 70289 invoked by uid 500); 2 May 2003 06:21:17 -0000 Mailing-List: contact dev-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Delivered-To: mailing list dev@perl.apache.org Received: (qmail 70254 invoked from network); 2 May 2003 06:21:16 -0000 Received: from erato.logilune.com (HELO mail.logilune.com) (195.154.174.52) by daedalus.apache.org with SMTP; 2 May 2003 06:21:16 -0000 Received: from stason.org (localhost.logilune.com [127.0.0.1]) by mail.logilune.com (Postfix) with ESMTP id B2D5A79895; Fri, 2 May 2003 08:21:25 +0200 (CEST) Message-ID: <3EB20E61.3080501@stason.org> Date: Fri, 02 May 2003 16:21:21 +1000 From: Stas Bekman Organization: Hope, Humanized User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Geoffrey Young Cc: dev@perl.apache.org Subject: Re: mod_include #perl support References: <3EB01ED1.5070601@modperlcookbook.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Geoffrey Young wrote: > hi all > > I've been working on extending mod_include to support the #perl tag the > way it did in 1.0. actually, I'm going a bit beyond that - I have a > preliminary implementation that (hopefully) will allow you to plug your > own perl callbacks into mod_include for tag parsing. > > as it turns out, this is all *much, much* more complex than I had > thought of at first - implementing #perl wasn't so bad, but creating a > callback mechanism was pretty rough (more on that in another post...) > > the larger problem I can't get past, which will affect everyone, is > getting the called Perl handler to insert data into the bucket brigade > properly. mod_cgi handles "cmd" like this > > bcgi = apr_brigade_create(r->pool, f->c->bucket_alloc); > b = apr_bucket_pipe_create(script_in, f->c->bucket_alloc); > APR_BRIGADE_INSERT_TAIL(bcgi, b); > ap_pass_brigade(f->next, bcgi); > > which I assume is roughly equivalent to > > my $brigade = APR::Brigade->new($f->r->pool, $f->c->bucket_alloc); > my $b = APR::Bucket->new("some data"); > $brigade->insert_tail($b); > my $rv = $f->next->pass_brigade($brigade); > return $rv unless $rv == APR::SUCCESS; > > but the output I get is all whacked (recognizable, but in the wrong order). > > anyway, stas if you have the inclination to take a look my basic #perl > implementation, that would be cool - I've spent a few days on this and > can't figure it out. tests 1 and 2 work ok, but test 3 for me gives > > # expected: content *** whee *** here > # received: *** whee ***content here > > and remember, the implementation is _really_ rough :) > > http://www.modperlcookbook.org/~geoff/modules/experimental/Apache-SSI-2.0.tar.gz Very cool, Geoff! You had a tiny problem, you haven't called SPLIT_AND_PASS_PRETAG_BUCKETS. The patch below makes things working. Unrelated to the problem you have asked about, here are a few more inputs: - dunno why you were trying to pass "APR::Brigade", but as you can see in the patch, you have a typo. (I guess you were trying to make it look like a normal filter). If so why don't you take the data from the tag create a bucket brigade in the XS and pass it to the handler. In that case you will allow to really have a filter. See what I mean? Parse the data as you do now, but don't push it into args, instead create a new bb in C and pass *it* to the handler in $bb. - in tests you must check if the request has succeeded. we have some bug with -port select, and it was failing for me when I used it without any error indicating. To make things simple there is *_BODY_ASSERT shortcut. You can see it in the patch. It'll assert if the request has failed. please forgive me for rewriting all *t files, it's just so much easier to have only 2 lines that need to be modified on top and keeping the rest of the code indentical everywhere. Again, kudos for a good work. --- Apache-SSI-2.0.orig/SSI.xs 2003-05-02 14:23:34.000000000 +1000 +++ Apache-SSI-2.0/SSI.xs 2003-05-02 16:14:22.000000000 +1000 @@ -41,7 +41,7 @@ modperl_handler_make_args(aTHX_ &av, "Apache::Filter", f, - "APR::Brigade", f, + "APR::Brigade", bb, NULL); while (1) { @@ -58,6 +58,14 @@ return 1; } } + + { + apr_status_t retval = APR_SUCCESS; + SPLIT_AND_PASS_PRETAG_BUCKETS(*bb, ctx, f->next, retval); + if (retval != APR_SUCCESS) { + return retval; + } + } if (!strcmp(tag, "arg")) { diff -ru Apache-SSI-2.0.orig/t/01perl.t Apache-SSI-2.0/t/01perl.t --- Apache-SSI-2.0.orig/t/01perl.t 2003-05-02 14:23:34.000000000 +1000 +++ Apache-SSI-2.0/t/01perl.t 2003-05-02 16:10:11.000000000 +1000 @@ -9,7 +9,9 @@ plan tests => 1, have_lwp; -my $response = GET '/ssi/perl.shtml'; -chomp(my $content = $response->content); +my $url = '/ssi/perl.shtml'; +my $expected = q!perl here!; -ok t_cmp(q!perl here!, $content); +my $received = GET_BODY_ASSERT $url; +chomp $received; +ok t_cmp($expected, $received); diff -ru Apache-SSI-2.0.orig/t/02die.t Apache-SSI-2.0/t/02die.t --- Apache-SSI-2.0.orig/t/02die.t 2003-05-02 14:23:34.000000000 +1000 +++ Apache-SSI-2.0/t/02die.t 2003-05-02 16:12:08.000000000 +1000 @@ -9,7 +9,9 @@ plan tests => 1, have_lwp; -my $response = GET '/ssi/die.shtml'; -chomp(my $content = $response->content); +my $url = '/ssi/die.shtml'; +my $expected = q!die [an error occurred while processing this directive] here!; -ok t_cmp(q!die [an error occurred while processing this directive] here!, $content); +my $received = GET_BODY_ASSERT $url; +chomp $received; +ok t_cmp($expected, $received); diff -ru Apache-SSI-2.0.orig/t/03content.t Apache-SSI-2.0/t/03content.t --- Apache-SSI-2.0.orig/t/03content.t 2003-05-02 14:23:34.000000000 +1000 +++ Apache-SSI-2.0/t/03content.t 2003-05-02 16:09:25.000000000 +1000 @@ -9,7 +9,9 @@ plan tests => 1, have_lwp; -my $response = GET '/ssi/content.shtml'; -chomp(my $content = $response->content); +my $url = '/ssi/content.shtml'; +my $expected = q!content *** whee *** here!; -ok t_cmp(q!content *** whee *** here!, $content); +my $received = GET_BODY_ASSERT $url; +chomp $received; +ok t_cmp($expected, $received); __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:stas@stason.org http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org For additional commands, e-mail: dev-help@perl.apache.org