httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Issac Goldstand <mar...@beamartyr.net>
Subject Re: server side includes
Date Tue, 10 Apr 2007 06:20:22 GMT


Nick Kew wrote:
> On Mon, 09 Apr 2007 23:31:32 +0300
> Issac Goldstand <margol@beamartyr.net> wrote:
> 
>> You'd probably just use output filters to parse the output stream and
>> add content according to what you find...  I don't have a C example,
>> but do have a Perl example (string parsing is just soooo much more
>> trivial with Perl than C) at
>> http://search.cpan.org/src/ISAAC/Apache-UploadMeter-0.9915/lib/Apache/UploadMeter.pm
>> (search for "### Output filters").  One replaces a "custom" tag, and
>> one simply includes HTML at the beginning of <head>
> 
> You can't just do that in any language unless you make a BIG performance
> sacrifice.  The basic problem is that "<head>", or any other pattern of
> more than one byte, might be split over more than one call to your
> filter function.  Techniques for dealing with that are of course
> described in my book.

I do consider that.  After reading the buckets (And before analyzing
them), I do

$buf = ${$f->ctx}{leftover}.$buf if defined(${$f->ctx}{leftover});
(prepend f->ctx->leftover onto buf)

and anything leftover that doesn't include a full HTML tag goes to

${$f->ctx}{leftover} = $buf || undef;

Of course, if we had a big resource with no HTML, we'd be in pretty big
trouble as everything would go into leftover, but this particular module
doesn't, in general, need to deal with that particular problem - at
least not where this filter might be injected.

> 
> 
>> Sam Carleton wrote:
>>> As I sit here on hold, I started thinking about my little apache
>>> module again.  I recall reading in "Writing Apache Modules in Perl
>>> and C" how with Perl it is quick and easy to create a server side
> 
> That book is very, very old.  Apache 1.x didn't have filters, so
> SSI was altogether more primitive.
> 
>>> include handler, I think that is what it was called.  How would one
>>> go about doing that in a C module?  Are there any examples?
> 
> ... and I don't know what it refers to as an SSI handler (I expect
> a primitive mod_include alternative).
> 

It is exactly that, IIRC.  It's been a few years since I read the eagle
book.

  Issac

Mime
View raw message