Under Apache 2.0, modules have the ability to filter content before sending it to the remote client. This incorporates several different APIs. First, the module must register the filter via the register_output_filter method (see the section called register_output_filter). Secondly, the PyMod must add the hook to the filter chain somewhere within the request phase. For output filters, this is commonly done at either post read request time, or in the insert_filters hook. Lastly, when the filter is called, it must utilitize both the filter API, and the bucket brigade API to manipulate content before sending it to the client or next filter.
filter.name
This string attribute contains the name of the filter, as specified when calling register_output_filter. (See the section called register_output_filter)
filter.pass_brigade( brigade)
brigade - The bucket brigade to pass down the filter chain.
When a filter is to be given a new chunk of data to process, whether from a content generator, or another filter, this routine can be called to start the processing. Subsequent filters should pass the data down the chain until the data is either written to the client, discarded, or buffered.
filter.next
The next attribute points to the next filter in the filter chain. This is commonly used from within a filter, to pass the brigade on to the next filter.
filter.ctx
The ctx parameter contains callback data, as given by the PyMod, when the filter was added. (See the section called add_output_filter)