<html xmlns="http://www.w3.org/TR/xhtml1/strict"><head><!-- 
          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                This file is generated from xml source: DO NOT EDIT
          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        --><title>mod_ext_filter- Apache HTTP Server</title><link href="../style/manual.css" type="text/css" rel="stylesheet"/></head><body><blockquote><div align="center"><img src="../images/sub.gif" alt="[APACHE DOCUMENTATION]"/><h3>Apache HTTP Server Version 2.0</h3></div><h1 align="center">Apache Module mod_ext_filter</h1><table cellspacing="1" cellpadding="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td valign="top"><span class="help">Description:</span></td><td>Pass the response body
    through an external program before delivery to the
    client</td></tr><tr><td><a href="module-dict.html#Status" class="help">Status:</a></td><td>Experimental</td></tr><tr><td><a href="module-dict.html#ModuleIdentifier" class="help">Module&nbsp;Identifier:</a></td><td>ext_filter_module</td></tr></table></td></tr></table><h2>Summary</h2>
    <p>This is an <strong>experimental</strong> module and should
    be used with care. Test your <code><a href="mod_ext_filter.html">mod_ext_filter</a></code>
    configuration carefully to ensure that it performs the desired
    function. You may wish to review <a href="../filter.html">
    this information</a> for background on the Apache filtering 
    model.</p>

    <p><code><a href="mod_ext_filter.html">mod_ext_filter</a></code> presents a simple and familiar
    programming model for filters. With this module, a program
    which reads from stdin and writes to stdout (i.e., a Unix-style
    filter command) can be a filter for Apache. This filtering
    mechanism is much slower than using a filter which is specially
    written for the Apache API and runs inside of the Apache server
    process, but it does have the following benefits:</p>

    <ul>
      <li>the programming model is much simpler</li>

      <li>any programming/scripting language can be used, provided
      that it allows the program to read from standard input and
      write to standard output</li>

      <li>existing programs can be used unmodified as Apache
      filters</li>
    </ul>

    <p>Even when the performance characteristics are not suitable
    for production use, <code>mod_ext_filter</code> can be used as
    a prototype environment for filters.</p>
<h2>Directives</h2><ul><li><a href="#extfilterdefine">ExtFilterDefine</a></li><li><a href="#extfilteroptions">ExtFilterOptions</a></li></ul><h2>Examples</h2>

<h3>Generating HTML from some other type of response</h3>
<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
<pre>
    # mod_ext_filter directive to define a filter to HTML-ize text/c files 
    # using the external program /usr/bin/enscript, with the type of the 
    # result set to text/html
    ExtFilterDefine c-to-html mode=output intype=text/c outtype=text/html \
                    cmd="/usr/bin/enscript --color -W html -Ec -o - -"

    &lt;Directory "/export/home/trawick/apacheinst/htdocs/c"&gt;

    # core directive to cause the new filter to be run on output
    SetOutputFilter c-to-html

    # mod_mime directive to set the type of .c files to text/c
    AddType text/c .c

    # mod_ext_filter directive to set the debug level just high 
    # enough to see a log message per request showing the configuration
    # in force
    ExtFilterOptions DebugLevel=1

    &lt;/Directory&gt;
</pre>
</code></td></tr></table></blockquote>


<h3>Implementing a content encoding filter</h3>
<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
<pre>
  # mod_ext_filter directive to define the external filter
  ExtFilterDefine gzip mode=output cmd=/bin/gzip

  &lt;Location /gzipped&gt;

  # core directive to cause the gzip filter to be run on output
  SetOutputFilter gzip

  # mod_header directive to add "Content-Encoding: gzip" header field
  Header set Content-Encoding gzip

  &lt;/Location&gt;
</pre>
</code></td></tr></table></blockquote>

  <p>Note: this gzip example is just for the purposes of illustration.
  Please refer to <code><a href="mod_deflate.html">mod_deflate</a></code> for a practical
  implementation.</p>


<h3>Slowing down the server</h3>
<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
<pre>
  # mod_ext_filter directive to define a filter which runs everything 
  # through cat; cat doesn't modify anything; it just introduces extra
  # pathlength and consumes more resources
  ExtFilterDefine slowdown mode=output cmd=/bin/cat preservescontentlength

  &lt;Location /&gt;

  # core directive to cause the slowdown filter to be run several times on 
  # output
  SetOutputFilter slowdown slowdown slowdown

  &lt;/Location&gt;
</pre>
</code></td></tr></table></blockquote>


<hr/><h2><a name="ExtFilterDefine">ExtFilterDefine</a> <a name="extfilterdefine">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description: </strong></td><td/></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:</a></td><td>ExtFilterDefine <em>filtername</em> <em>parameters</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:</a></td><td>server config</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:</a></td><td>Experimental</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:</a></td><td>mod_ext_filter</td></tr></table></td></tr></table>
    <p>The <code class="directive">ExtFilterDefine</code> directive defines the
    characteristics of an external filter, including the program to
    run and its arguments.</p>

    <p><em>filtername</em> specifies the name of the filter being
    defined. This name can then be used in SetOutputFilter
    directives. It must be unique among all registered filters.
    <em>At the present time, no error is reported by the
    register-filter API, so a problem with duplicate names isn't
    reported to the user.</em></p>

    <p>Subsequent parameters can appear in any order and define the
    external command to run and certain other characteristics. The
    only required parameter is <em>cmd=</em>. These parameters
    are:</p>

    <dl>
      <dt>cmd=<em>cmdline</em></dt>

      <dd>The <code>cmd=</code> keyword allows you to specify the
      external command to run. If there are arguments after the
      program name, the command line should be surrounded in
      quotation marks.</dd>

      <dt>mode=<em>mode</em></dt>

      <dd><em>mode</em> should be <em>output</em> for now (the
      default). In the future, <em>mode=input</em> will be used to
      specify a filter for request bodies.</dd>

      <dt>intype=<em>imt</em></dt>

      <dd>This parameter specifies the internet media type (i.e.,
      MIME type) of documents which should be filtered. By default,
      all documents are filtered. If <code>intype=</code> is
      specified, the filter will be disabled for documents of other
      types.</dd>

      <dt>outtype=<em>imt</em></dt>

      <dd>This parameter specifies the internet media type (i.e.,
      MIME type) of filtered documents. It is useful when the
      filter changes the internet media type as part of the
      filtering operation. By default, the internet media type is
      unchanged.</dd>

      <dt>PreservesContentLength</dt>

      <dd>The <code>PreservesContentLength</code> keyword specifies
      that the filter preserves the content length. This is not the
      default, as most filters change the content length. In the
      event that the filter doesn't modify the length, this keyword
      should be specified.</dd>
    </dl>
<hr/><h2><a name="ExtFilterOptions">ExtFilterOptions</a> <a name="extfilteroptions">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description: </strong></td><td/></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:</a></td><td>ExtFilterOptions
    <em>option</em> [<em>option</em>] ...</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Default" class="help">Default:</a></td><td><code>ExtFilterOptions DebugLevel=0 NoLogStderr</code></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:</a></td><td>directory</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:</a></td><td>Experimental</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:</a></td><td>mod_ext_filter</td></tr></table></td></tr></table>
    <p>The <code class="directive">ExtFilterOptions</code> directive specifies
    special processing options for <code>mod_ext_filter</code>.
    <em>Option</em> can be one of</p>

    <dl>
      <dt>DebugLevel=<em>n</em></dt>

      <dd>
        The <code>DebugLevel</code> keyword allows you to specify
        the level of debug messages generated by
        <code>mod_ext_filter</code>. By default, no debug messages
        are generated. This is equivalent to
        <code>DebugLevel=0</code>. With higher numbers, more debug
        messages are generated, and server performance will be
        degraded. The actual meanings of the numeric values are
        described with the definitions of the DBGLVL_ constants
        near the beginning of <code>mod_ext_filter.c</code>. 

        <p>Note: The core directive LogLevel should be used to
        cause debug messages to be stored in the Apache error
        log.</p>
      </dd>

      <dt>LogStderr | NoLogStderr</dt>

      <dd>The <code>LogStderr</code> keyword specifies that
      messages written to standard error by the external filter
      program will be saved in the Apache error log.
      <code>NoLogStderr</code> disables this feature.</dd>
    </dl>

     <p>Example:</p>
<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
    ExtFilterOptions  LogStderr DebugLevel=0
</code></td></tr></table></blockquote>

    <p>Messages written to the filter's standard error will be stored
    in the Apache error log. No debug messages will be generated by
    <code><a href="mod_ext_filter.html">mod_ext_filter</a></code>. </p>
<hr/></blockquote><h3 align="center">Apache HTTP Server Version 2.0</h3><a href="./"><img src="../images/index.gif" alt="Index"/></a><a href="../"><img src="../images/home.gif" alt="Home"/></a></body></html>