[Previous] [Next] [Up] [Top] [Search] [Index]

Filters


An arbitrary "filter" can be assigned to any file to be served. A filter is a program which reads the file and has the program output served rather than the content of the file. One common use of this feature is for on-the-fly decompression. For, example a file can be stored in its compressed form and assigned a filter like zcat which uncompresses it. Then the client is served the uncompressed file but only the compressed version is stored on disk. As another example, you might use "nroff -man" as a filter to process UNIX man files before serving. There are many other interesting uses of filters. Be creative!

A filter is assigned to a file by use of the Filter= directive in the file's record in its index.cache file. For example, the lines

File=foo.gz
Content-type=text/plain
Filter=/usr/local/bin/zcat
Content-encoding=none

cause the compressed file foo.gz to be uncompressed on the fly and served to the client as a text/plain document. Notice that it is necessary to have the content-encoding line to override the default action of wndex which is to infer from the ".gz" suffix that the content-encoding is x-gzip. If the compressed file were named simply "foo" then the content-encoding line would be unnecessary.

The Filter= directive takes the value of a path to a file in three different forms. If the path begins with a '/' then it is relative to the system root. If it begins with ~/ then it is relative to the WN hierarchy root, and otherwise it is relative to the directory containing the index file.

The ability to filter files can be restricted in several ways. If WN is invoked with the -e option then no includes, filters, or CGI programs will be executed.

The -E option in conjunction with the -t or -T options restricts the use of filters to those listed in index.cache files owned by trusted users or groups. The -u option allows only the use of filters owned by the owner of the index.cache file which lists them.

If you wish to have all the standard CGI environment variables made available to the filter program you can do so by adding the line

Attributes=CGI
to the file record. A list of these environment variables can be found in the Appendix D. (Also see the sample CGI script which is located in the file /docs/examples/sample.cgi which accompainies the WN distribution.)


John Franks <john@math.nwu.edu>
[Previous] [Next] [Up] [Top] [Search] [Index]