GuidesFiltering I/O in Apache 2.0: Part 2 Page 4

Filtering I/O in Apache 2.0: Part 2 Page 4




All we have left to do now, is re-compile the server with our new
module and set it up to use the header and footer module.
In this case, adding the filter to the filter chain is best done in the config
file with the AddOutputFilter directive which is defined by the core. Edit your
config file and find the Directory stanza for the directory you wish to add a
header or footer to. The AddOutputFilter directive takes the name of the filter
to add as its argument. In this case it is HEADERFOOTER. As long as we are here,
let’s also add two lines to add a header and footer file to the files in this
directory. Be careful when adding a header and footer to a page. If you add a
header file to a whole directory, and the header file is in that directory, then
your server will recursively send the header file forever. In the configuration
below, we are only adding the header and footer for the index page.

    AddOutputFilter HEADERFOOTER
    
        HeaderFile header
        HeaderText "This is a header text"
        FooterFile footer
        FooterText "This is a footer text"
    

That was a very basic introduction to output filtering. Next month, we continue
looking into Apache 2.0's filtering with input filtering. This will allow your
module to modify the data that a browser sends on a POST or PUT request. I should
also mention here that filtering is still evolving. This module works with
Apache as it is right now. This module has not been tested with any of the
official alpha releases of 2.0, but with slight modifications, it should work with
any of the alphas after alpha 7.

You can download the mod_hf.c file here.

Latest Posts

Related Stories