An output filter is given
a bucket brigade, does whatever it
does, and hands a new brigade (or brigades) down to the next filter
in the output filter stack. To be used at all, a filter must first be
registered. This is normally done in the hook registering function by
ap_register_output_filter(), like so:
where the first parameter is the name of the filter — this can be
used in the configuration file to specify when a filter should be
used. The second is the actual filter function, and the third says
what type of filter it is (the possible types being
AP_FTYPE_NETWORK). In reality, all the type does
is determine where in the stack the filter appears. The filter
function is called by the filter above it in the stack, which hands
it its filter structure and a bucket brigade.
Once the filter is registered, it can be invoked either by configuration, or for more complex cases, the module can decide whether to insert it in the filter stack. If this is desired, the thing to do is to hook the “insert filter” hook, which is called when the filter stack is being set up. A typical hook would look like this:
filter_inserter() is a function that decides whether to insert the filter, and if so, inserts it. To do the insertion ...