upload http
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / docs / manual / mod / mod_ext_filter.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5               This file is generated from xml source: DO NOT EDIT
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7       -->
8 <title>mod_ext_filter - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
13 <body>
14 <div id="page-header">
15 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
16 <p class="apache">Apache HTTP Server Version 2.0</p>
17 <img alt="" src="../images/feather.gif" /></div>
18 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
19 <div id="path">
20 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.0</a> &gt; <a href="./">Modules</a></div>
21 <div id="page-content">
22 <div id="preamble"><h1>Apache Module mod_ext_filter</h1>
23 <div class="toplang">
24 <p><span>Available Languages: </span><a href="../en/mod/mod_ext_filter.html" title="English">&nbsp;en&nbsp;</a> |
25 <a href="../ko/mod/mod_ext_filter.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
26 </div>
27 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Pass the response body through an external program before
28 delivery to the client</td></tr>
29 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
30 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>ext_filter_module</td></tr>
31 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_ext_filter.c</td></tr></table>
32 <h3>Summary</h3>
33
34     <p><code class="module"><a href="../mod/mod_ext_filter.html">mod_ext_filter</a></code> presents a simple and familiar
35     programming model for <a href="../filter.html">filters</a>. With
36     this module, a program which reads from stdin and writes to stdout
37     (i.e., a Unix-style filter command) can be a filter for
38     Apache. This filtering mechanism is much slower than using a
39     filter which is specially written for the Apache API and runs
40     inside of the Apache server process, but it does have the
41     following benefits:</p>
42
43     <ul>
44       <li>the programming model is much simpler</li>
45
46       <li>any programming/scripting language can be used, provided
47       that it allows the program to read from standard input and
48       write to standard output</li>
49
50       <li>existing programs can be used unmodified as Apache
51       filters</li>
52     </ul>
53
54     <p>Even when the performance characteristics are not suitable
55     for production use, <code class="module"><a href="../mod/mod_ext_filter.html">mod_ext_filter</a></code> can be used as
56     a prototype environment for filters.</p>
57
58 </div>
59 <div id="quickview"><h3 class="directives">Directives</h3>
60 <ul id="toc">
61 <li><img alt="" src="../images/down.gif" /> <a href="#extfilterdefine">ExtFilterDefine</a></li>
62 <li><img alt="" src="../images/down.gif" /> <a href="#extfilteroptions">ExtFilterOptions</a></li>
63 </ul>
64 <h3>Topics</h3>
65 <ul id="topics">
66 <li><img alt="" src="../images/down.gif" /> <a href="#examples">Examples</a></li>
67 </ul><h3>See also</h3>
68 <ul class="seealso">
69 <li><a href="../filter.html">Filters</a></li>
70 </ul></div>
71 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
72 <div class="section">
73 <h2><a name="examples" id="examples">Examples</a></h2>
74
75     <h3>Generating HTML from some other type of response</h3>
76       <div class="example"><p><code>
77         # mod_ext_filter directive to define a filter<br />
78         # to HTML-ize text/c files using the external<br />
79         # program /usr/bin/enscript, with the type of<br />
80         # the result set to text/html<br />
81         ExtFilterDefine c-to-html mode=output \<br />
82         <span class="indent">
83           intype=text/c outtype=text/html \<br />
84           cmd="/usr/bin/enscript --color -W html -Ec -o - -"<br />
85         </span>
86         <br />
87         &lt;Directory "/export/home/trawick/apacheinst/htdocs/c"&gt;<br />
88         <span class="indent">
89           # core directive to cause the new filter to<br />
90           # be run on output<br />
91           SetOutputFilter c-to-html<br />
92           <br />
93           # mod_mime directive to set the type of .c<br />
94           # files to text/c<br />
95           AddType text/c .c<br />
96           <br />
97           # mod_ext_filter directive to set the debug<br />
98           # level just high enough to see a log message<br />
99           # per request showing the configuration in force<br />
100           ExtFilterOptions DebugLevel=1<br />
101         </span>
102         &lt;/Directory&gt;
103       </code></p></div>
104     
105
106     <h3>Implementing a content encoding filter</h3>
107       <p>Note: this gzip example is just for the purposes of illustration.
108       Please refer to <code class="module"><a href="../mod/mod_deflate.html">mod_deflate</a></code> for a practical
109       implementation.</p>
110
111       <div class="example"><p><code>
112         # mod_ext_filter directive to define the external filter<br />
113         ExtFilterDefine gzip mode=output cmd=/bin/gzip<br />
114         <br />
115         &lt;Location /gzipped&gt;<br />
116         <span class="indent">
117           # core directive to cause the gzip filter to be<br />
118           # run on output<br />
119           SetOutputFilter gzip<br />
120           <br />
121           # mod_header directive to add<br />
122           # "Content-Encoding: gzip" header field<br />
123           Header set Content-Encoding gzip<br />
124         </span>
125         &lt;/Location&gt;
126       </code></p></div>
127     
128
129     <h3>Slowing down the server</h3>
130       <div class="example"><p><code>
131         # mod_ext_filter directive to define a filter<br />
132         # which runs everything through cat; cat doesn't<br />
133         # modify anything; it just introduces extra pathlength<br />
134         # and consumes more resources<br />
135         ExtFilterDefine slowdown mode=output cmd=/bin/cat \<br />
136         <span class="indent">
137           preservescontentlength<br />
138         </span>
139         <br />
140         &lt;Location /&gt;<br />
141         <span class="indent">
142           # core directive to cause the slowdown filter to<br />
143           # be run several times on output<br />
144           #<br />
145           SetOutputFilter slowdown;slowdown;slowdown<br />
146         </span>
147         &lt;/Location&gt;
148       </code></p></div>
149     
150
151     <h3>Using sed to replace text in the response</h3>
152       <div class="example"><p><code>
153         # mod_ext_filter directive to define a filter which<br />
154         # replaces text in the response<br />
155         #<br />
156         ExtFilterDefine fixtext mode=output intype=text/html \<br />
157         <span class="indent">
158           cmd="/bin/sed s/verdana/arial/g"<br />
159         </span>
160         <br />
161         &lt;Location /&gt;<br />
162         <span class="indent">
163           # core directive to cause the fixtext filter to<br />
164           # be run on output<br />
165           SetOutputFilter fixtext<br />
166         </span>
167         &lt;/Location&gt;
168       </code></p></div>
169     
170
171     <h3>Tracing another filter</h3>
172       <div class="example"><p><code>
173         # Trace the data read and written by mod_deflate<br />
174         # for a particular client (IP 192.168.1.31)<br />
175         # experiencing compression problems.<br />
176         # This filter will trace what goes into mod_deflate.<br />
177         ExtFilterDefine tracebefore \<br />
178         <span class="indent">
179           cmd="/bin/tracefilter.pl /tmp/tracebefore" \<br />
180           EnableEnv=trace_this_client<br />
181         </span>
182         <br />
183         # This filter will trace what goes after mod_deflate.<br />
184         # Note that without the ftype parameter, the default<br />
185         # filter type of AP_FTYPE_RESOURCE would cause the<br />
186         # filter to be placed *before* mod_deflate in the filter<br />
187         # chain.  Giving it a numeric value slightly higher than<br />
188         # AP_FTYPE_CONTENT_SET will ensure that it is placed<br />
189         # after mod_deflate.<br />
190         ExtFilterDefine traceafter \<br />
191         <span class="indent">
192           cmd="/bin/tracefilter.pl /tmp/traceafter" \<br />
193           EnableEnv=trace_this_client ftype=21<br />
194         </span>
195         <br />
196         &lt;Directory /usr/local/docs&gt;<br />
197         <span class="indent">
198           SetEnvIf Remote_Addr 192.168.1.31 trace_this_client<br />
199           SetOutputFilter tracebefore;deflate;traceafter<br />
200         </span>
201         &lt;/Directory&gt;
202       </code></p></div>
203
204       <div class="example"><h3>Here is the filter which traces the data:</h3><p><code>
205         #!/usr/local/bin/perl -w<br />
206         use strict;<br />
207         <br />
208         open(SAVE, "&gt;$ARGV[0]")<br />
209         <span class="indent">
210           or die "can't open $ARGV[0]: $?";<br />
211         </span>
212         <br />
213         while (&lt;STDIN&gt;) {<br />
214         <span class="indent">
215           print SAVE $_;<br />
216           print $_;<br />
217         </span>
218         }<br />
219         <br />
220         close(SAVE);
221       </code></p></div>
222     
223 </div>
224 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
225 <div class="directive-section"><h2><a name="ExtFilterDefine" id="ExtFilterDefine">ExtFilterDefine</a> <a name="extfilterdefine" id="extfilterdefine">Directive</a></h2>
226 <table class="directive">
227 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Define an external filter</td></tr>
228 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ExtFilterDefine <var>filtername</var> <var>parameters</var></code></td></tr>
229 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
230 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
231 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_ext_filter</td></tr>
232 </table>
233     <p>The <code class="directive">ExtFilterDefine</code> directive defines the
234     characteristics of an external filter, including the program to
235     run and its arguments.</p>
236
237     <p><var>filtername</var> specifies the name of the filter being
238     defined. This name can then be used in SetOutputFilter
239     directives. It must be unique among all registered filters.
240     <em>At the present time, no error is reported by the
241     register-filter API, so a problem with duplicate names isn't
242     reported to the user.</em></p>
243
244     <p>Subsequent parameters can appear in any order and define the
245     external command to run and certain other characteristics. The
246     only required parameter is <code>cmd=</code>. These parameters
247     are:</p>
248
249     <dl>
250       <dt><code>cmd=<var>cmdline</var></code></dt>
251
252       <dd>The <code>cmd=</code> keyword allows you to specify the
253       external command to run. If there are arguments after the
254       program name, the command line should be surrounded in
255       quotation marks (<em>e.g.</em>, <code>cmd="<var>/bin/mypgm</var>
256       <var>arg1</var> <var>arg2</var>"</code>. Normal shell quoting is
257       not necessary since the program is run directly, bypassing the shell.
258       Program arguments are blank-delimited. A backslash can be used to
259       escape blanks which should be part of a program argument. Any
260       backslashes which are part of the argument must be escaped with
261       backslash themselves.  In addition to the standard CGI environment
262       variables, DOCUMENT_URI, DOCUMENT_PATH_INFO, and 
263       QUERY_STRING_UNESCAPED will also be set for the program.</dd>
264
265       <dt><code>mode=<var>mode</var></code></dt>
266
267       <dd><code>mode</code> should be <code>output</code> for now (the
268       default). In the future, <code>mode=input</code> will be used to
269       specify a filter for request bodies.</dd>
270
271       <dt><code>intype=<var>imt</var></code></dt>
272
273       <dd>This parameter specifies the internet media type (<em>i.e.</em>,
274       MIME type) of documents which should be filtered. By default,
275       all documents are filtered. If <code>intype=</code> is
276       specified, the filter will be disabled for documents of other
277       types.</dd>
278
279       <dt><code>outtype=<var>imt</var></code></dt>
280
281       <dd>This parameter specifies the internet media type (<em>i.e.</em>,
282       MIME type) of filtered documents. It is useful when the
283       filter changes the internet media type as part of the
284       filtering operation. By default, the internet media type is
285       unchanged.</dd>
286
287       <dt><code>PreservesContentLength</code></dt>
288
289       <dd>The <code>PreservesContentLength</code> keyword specifies
290       that the filter preserves the content length. This is not the
291       default, as most filters change the content length. In the
292       event that the filter doesn't modify the length, this keyword
293       should be specified.</dd>
294
295       <dt><code>ftype=<var>filtertype</var></code></dt>
296
297       <dd>This parameter specifies the numeric value for filter type
298       that the filter should be registered as.  The default value,
299       AP_FTYPE_RESOURCE, is sufficient in most cases.  If the filter
300       needs to operate at a different point in the filter chain than
301       resource filters, then this parameter will be necessary.  See
302       the AP_FTYPE_foo definitions in util_filter.h for appropriate
303       values.</dd>
304
305       <dt><code>disableenv=<var>env</var></code></dt>
306
307       <dd>This parameter specifies the name of an environment variable
308       which, if set, will disable the filter.</dd>
309
310       <dt><code>enableenv=<var>env</var></code></dt>
311
312       <dd>This parameter specifies the name of an environment variable
313       which must be set, or the filter will be disabled.</dd>
314     </dl>
315
316 </div>
317 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
318 <div class="directive-section"><h2><a name="ExtFilterOptions" id="ExtFilterOptions">ExtFilterOptions</a> <a name="extfilteroptions" id="extfilteroptions">Directive</a></h2>
319 <table class="directive">
320 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Configure <code class="module"><a href="../mod/mod_ext_filter.html">mod_ext_filter</a></code> options</td></tr>
321 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ExtFilterOptions <var>option</var> [<var>option</var>] ...</code></td></tr>
322 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>ExtFilterOptions DebugLevel=0 NoLogStderr</code></td></tr>
323 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory</td></tr>
324 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
325 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_ext_filter</td></tr>
326 </table>
327     <p>The <code class="directive">ExtFilterOptions</code> directive specifies
328     special processing options for <code class="module"><a href="../mod/mod_ext_filter.html">mod_ext_filter</a></code>.
329     <var>Option</var> can be one of</p>
330
331     <dl>
332       <dt><code>DebugLevel=<var>n</var></code></dt>
333
334       <dd>
335         The <code>DebugLevel</code> keyword allows you to specify
336         the level of debug messages generated by
337         <code class="module"><a href="../mod/mod_ext_filter.html">mod_ext_filter</a></code>. By default, no debug messages
338         are generated. This is equivalent to
339         <code>DebugLevel=0</code>. With higher numbers, more debug
340         messages are generated, and server performance will be
341         degraded. The actual meanings of the numeric values are
342         described with the definitions of the DBGLVL_ constants
343         near the beginning of <code>mod_ext_filter.c</code>. 
344
345         <p>Note: The core directive <code class="directive"><a href="../mod/core.html#loglevel">LogLevel</a></code> should be used to cause debug messages to
346         be stored in the Apache error log.</p>
347       </dd>
348
349       <dt><code>LogStderr | NoLogStderr</code></dt>
350
351       <dd>The <code>LogStderr</code> keyword specifies that
352       messages written to standard error by the external filter
353       program will be saved in the Apache error log.
354       <code>NoLogStderr</code> disables this feature.</dd>
355     </dl>
356
357     <div class="example"><h3>Example</h3><p><code>
358       ExtFilterOptions LogStderr DebugLevel=0
359     </code></p></div>
360
361     <p>Messages written to the filter's standard error will be stored
362     in the Apache error log. No debug messages will be generated by
363     <code class="module"><a href="../mod/mod_ext_filter.html">mod_ext_filter</a></code>. </p>
364
365 </div>
366 </div>
367 <div class="bottomlang">
368 <p><span>Available Languages: </span><a href="../en/mod/mod_ext_filter.html" title="English">&nbsp;en&nbsp;</a> |
369 <a href="../ko/mod/mod_ext_filter.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
370 </div><div id="footer">
371 <p class="apache">Copyright 2009 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
372 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>
373 </body></html>