Filter sequence and runtime filter manipulation for non-mod_perl filters
dorian taylor <[email protected]>
| Newsgroups | gmane.comp.apache.mod-perl |
|---|---|
| Message-ID | <CAMrqWm0a00CJ3Vi91biw7BWGXaqqv_Zcs+8fr_mJDUeKALD7og@mail.gmail.com> |
I'm running into the perennial problem of not being able to mix
mod_perl and Apache C filters in the necessary order. Because I also
need the C filter (mod_transform) bound only to the right
Content-Type, I figure the easiest way to make it happen would be to
write a small no-op mod_perl filter that checks $f->r->content_type
and adds mod_transform to the chain.
Of course, Apache2::Filter->add_output_filter is only capable of
adding mod_perl filters.
Grepping the mod_perl source for instances of add_output_filter, I
found this: https://svn.apache.org/repos/asf/perl/modperl/trunk/todo/design_notes
Adding something like this to the bottom of modperl_filter_runtime_add
(in https://svn.apache.org/repos/asf/perl/modperl/trunk/src/modules/perl/modperl_filter.c
) should make the behaviour described there partially available:
else if (SvPOK(callback)) {
char *name = SvPVX(callback);
ap_filter_t *f = addfunc(name, NULL, r, c);
if (f) return;
Perl_croak(aTHX_ "Apache filter %s could not be resolved\n", name);
}
I say "partially" because that document calls for a $ctx to be passed
into the filter, but that makes no sense for filters written in C.
The behaviour I'm looking for is something like
$f->add_output_filter('XSLT') which is the handle for mod_transform.
I'm in the process of testing this code and importing the (1.6 million
rev) SVN repository into git so I can make a proper patch.
Any insights? Am I undertaking unnecessary yak-shaving?
(Note: I was hoping to be able to cargo-cult up a re-ordered sequence
with mod_filter, but that got me nowhere. Actually, it got me a
segfault.)
Thanks,
--
Dorian Taylor
http://doriantaylor.com/