Apache: read() compatible interface for output filter

Apache: read() compatible interface for output filter

Post by Nick K » Tue, 21 May 2002 08:26:44



In an apache handler, we read request data using ap_get_client_block,
which can be used as a drop-in replacement for read or fread in
libraries that expect such functions as callbacks.

A more complex partial equivalent can be used in a filter - eg with
ap_get_brigade in an input filter. But it is limited to a single call
to a filter function that may be called multiple times.
So it can only be used as a callback with the aid of a hack, such as
reading all the data into memory (and there is no apr_realloc) or to
a tmpfile.  I can't see any really satisfactory fix for this.

The kind of thing I'm doing is exemplified by mod_xml.  In the main handler
I can do things like (illustrative pseudo-code):

  parser->read_callback = ap_get_client_block ;
  parser->run() ;

But I'm having trouble trying to do the same in a filter, particularly
an output filter where I most often want it!

Any suggestions?

--
Nick Kew

Available for contract work - Programming, Unix, Networking, Markup, etc.

 
 
 

Apache: read() compatible interface for output filter

Post by Paul Rubi » Tue, 21 May 2002 10:21:05


I wrote a hack a while back that permitted multiple filters.  It
required a small change in one of the apache core files-- I forget the
details.  I could figure out no way to do it in Apache 1.3 without
such a change.  In 2.0 it may be possible.

I can dig out the code if you want it but it may take me a while.

 
 
 

Apache: read() compatible interface for output filter

Post by Nick K » Tue, 21 May 2002 12:09:28




Quote:> I wrote a hack a while back that permitted multiple filters.  It

With read()- compatible input?  It's not the number of filters I'm
interested in, but rather how any filter reads its input.

Quote:> required a small change in one of the apache core files--

That would rule it out for much, but not all, of what I want to do.
OTOH looking at your code with 2.0 might suggest a workaround.

(my alternative is to mess about with subrequests, but a filter should
be a much cleaner way to go).

Quote:> I can dig out the code if you want it but it may take me a while.

If it does what I'm asking then yes please!

--
Nick Kew

Available for contract work - Programming, Unix, Networking, Markup, etc.

 
 
 

Apache: read() compatible interface for output filter

Post by Paul Rubi » Tue, 21 May 2002 13:15:31



> > I wrote a hack a while back that permitted multiple filters.  It

> With read()- compatible input?  It's not the number of filters I'm
> interested in, but rather how any filter reads its input.

I'm not sure I understand your question.  Maybe we're not talking
about the same thing.  Part of the problem is I don't remember exactly
what I did.  It was something a client wanted a while back; I did it
and mostly forgot about it afterwards.  But as I remember, it allowed
modules to edit and inject stuff into the POST data stream that cgi's
would then see.  So I guess it was read() compatible.  It worked
by adding an additional hook to the place where the 1.3 EAPI normally
attached the SSL stack to the read function.

Quote:> > required a small change in one of the apache core files--

> That would rule it out for much, but not all, of what I want to do.
> OTOH looking at your code with 2.0 might suggest a workaround.

I guess so.  Part of the issue was my hack had to work in conjunction
with SSL.  My patch was in one of the EAPI support functions.  But I
think in 2.0 they eliminated a the EAPI hair and made SSL a standard
module.

Quote:> (my alternative is to mess about with subrequests, but a filter should
> be a much cleaner way to go).

I don't think subrequests could do what I did.  Can you describe
your problem more fully?

Quote:> > I can dig out the code if you want it but it may take me a while.

> If it does what I'm asking then yes please!

It looks like it's on another machine that I won't be able to get to
real soon, but I should retrieve it sometime and I'll put it on my web site.
Remind me in about 2 weeks if I have done it by then.
 
 
 

1. specify output interface on filtered packet?

[Cross-posted to comp.unix.bsd.freebsd.misc,
comp.unix.bsd.openbsd.misc and comp.os.linux.networking.]

Hello,

Is it possible (using IPFilter/IPFW/IPTable/PF) to specify which
interface a packet should be sent out on?

               _____
               |    |
  Internal ----| R  | fxp0 -----> HTTP/FTP/bulk  ---|
               |____|                               |
                fxp1                                \/
                 |--------> SSH/SMTP ---------> Internet

Depending on the filtering rules (in this case destination port), I
want to route packet(s) so they go out on a particular
interface. Each interface will have a different IP address (fxp0 will
actually be dynamic, and fxp1 static). There should not be routing
between fxp0 and fxp1.

All traffic from the internal network would also be NATed regardless
of the interface it goes out of.

I'm looking to do this on *BSD or Linux 2.4 (probably Debian). A
hardware router would be a third choice. (Linux may be the primary
choice because of internal support issues.)

Is doing what I want possible?

--
David Magda <dmagda at ee.ryerson.ca>, http://www.magda.ca/
Because the innovator has for enemies all those who have done well under
the old conditions, and lukewarm defenders in those who may do well
under the new. -- Niccolo Machiavelli, _The Prince_, Chapter VI

2. USB for Linux?

3. Apache 2.0 Output filters with mod_jk

4. RAID and Linux

5. Does anyone know how the output filter is called in the Apache core?

6. Install problems with rh 6.1 on AS800

7. Filtering in Apache a la ISAPI filters ?

8. RealAudio

9. Filters, Filters, where are you Filters...

10. Apache 2.0 on Red Hat 8.0 only outputs the Apache Test Page

11. Does anyone know of a VGA overlay board with NTSC compatible output?

12. Is an Iomega Tape 250 (floppy interface) compatible with RH Linux 5.1?

13. Interface compatible to IEEE 488