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
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>
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.2</p>
17
<img alt="" src="../images/feather.gif" /></div>
18
<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
20
<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a> > <a href="./">Modules</a></div>
21
<div id="page-content">
22
<div id="preamble"><h1>Apache Module mod_ext_filter</h1>
24
<p><span>Available Languages: </span><a href="../en/mod/mod_ext_filter.html" title="English"> en </a> |
25
<a href="../ja/mod/mod_ext_filter.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
26
<a href="../ko/mod/mod_ext_filter.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
28
<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Pass the response body through an external program before
29
delivery to the client</td></tr>
30
<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
31
<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>ext_filter_module</td></tr>
32
<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_ext_filter.c</td></tr></table>
35
<p><code class="module"><a href="../mod/mod_ext_filter.html">mod_ext_filter</a></code> presents a simple and familiar
36
programming model for <a href="../filter.html">filters</a>. With
37
this module, a program which reads from stdin and writes to stdout
38
(i.e., a Unix-style filter command) can be a filter for
39
Apache. This filtering mechanism is much slower than using a
40
filter which is specially written for the Apache API and runs
41
inside of the Apache server process, but it does have the
42
following benefits:</p>
45
<li>the programming model is much simpler</li>
47
<li>any programming/scripting language can be used, provided
48
that it allows the program to read from standard input and
49
write to standard output</li>
51
<li>existing programs can be used unmodified as Apache
55
<p>Even when the performance characteristics are not suitable
56
for production use, <code class="module"><a href="../mod/mod_ext_filter.html">mod_ext_filter</a></code> can be used as
57
a prototype environment for filters.</p>
60
<div id="quickview"><h3 class="directives">Directives</h3>
62
<li><img alt="" src="../images/down.gif" /> <a href="#extfilterdefine">ExtFilterDefine</a></li>
63
<li><img alt="" src="../images/down.gif" /> <a href="#extfilteroptions">ExtFilterOptions</a></li>
67
<li><img alt="" src="../images/down.gif" /> <a href="#examples">Examples</a></li>
68
</ul><h3>See also</h3>
70
<li><a href="../filter.html">Filters</a></li>
72
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
74
<h2><a name="examples" id="examples">Examples</a></h2>
76
<h3>Generating HTML from some other type of response</h3>
77
<div class="example"><p><code>
78
# mod_ext_filter directive to define a filter<br />
79
# to HTML-ize text/c files using the external<br />
80
# program /usr/bin/enscript, with the type of<br />
81
# the result set to text/html<br />
82
ExtFilterDefine c-to-html mode=output \<br />
84
intype=text/c outtype=text/html \<br />
85
cmd="/usr/bin/enscript --color -W html -Ec -o - -"<br />
88
<Directory "/export/home/trawick/apacheinst/htdocs/c"><br />
90
# core directive to cause the new filter to<br />
91
# be run on output<br />
92
SetOutputFilter c-to-html<br />
94
# mod_mime directive to set the type of .c<br />
95
# files to text/c<br />
96
AddType text/c .c<br />
98
# mod_ext_filter directive to set the debug<br />
99
# level just high enough to see a log message<br />
100
# per request showing the configuration in force<br />
101
ExtFilterOptions DebugLevel=1<br />
107
<h3>Implementing a content encoding filter</h3>
108
<p>Note: this gzip example is just for the purposes of illustration.
109
Please refer to <code class="module"><a href="../mod/mod_deflate.html">mod_deflate</a></code> for a practical
112
<div class="example"><p><code>
113
# mod_ext_filter directive to define the external filter<br />
114
ExtFilterDefine gzip mode=output cmd=/bin/gzip<br />
116
<Location /gzipped><br />
117
<span class="indent">
118
# core directive to cause the gzip filter to be<br />
119
# run on output<br />
120
SetOutputFilter gzip<br />
122
# mod_header directive to add<br />
123
# "Content-Encoding: gzip" header field<br />
124
Header set Content-Encoding gzip<br />
130
<h3>Slowing down the server</h3>
131
<div class="example"><p><code>
132
# mod_ext_filter directive to define a filter<br />
133
# which runs everything through cat; cat doesn't<br />
134
# modify anything; it just introduces extra pathlength<br />
135
# and consumes more resources<br />
136
ExtFilterDefine slowdown mode=output cmd=/bin/cat \<br />
137
<span class="indent">
138
preservescontentlength<br />
141
<Location /><br />
142
<span class="indent">
143
# core directive to cause the slowdown filter to<br />
144
# be run several times on output<br />
146
SetOutputFilter slowdown;slowdown;slowdown<br />
152
<h3>Using sed to replace text in the response</h3>
153
<div class="example"><p><code>
154
# mod_ext_filter directive to define a filter which<br />
155
# replaces text in the response<br />
157
ExtFilterDefine fixtext mode=output intype=text/html \<br />
158
<span class="indent">
159
cmd="/bin/sed s/verdana/arial/g"<br />
162
<Location /><br />
163
<span class="indent">
164
# core directive to cause the fixtext filter to<br />
165
# be run on output<br />
166
SetOutputFilter fixtext<br />
172
<h3>Tracing another filter</h3>
173
<div class="example"><p><code>
174
# Trace the data read and written by mod_deflate<br />
175
# for a particular client (IP 192.168.1.31)<br />
176
# experiencing compression problems.<br />
177
# This filter will trace what goes into mod_deflate.<br />
178
ExtFilterDefine tracebefore \<br />
179
<span class="indent">
180
cmd="/bin/tracefilter.pl /tmp/tracebefore" \<br />
181
EnableEnv=trace_this_client<br />
184
# This filter will trace what goes after mod_deflate.<br />
185
# Note that without the ftype parameter, the default<br />
186
# filter type of AP_FTYPE_RESOURCE would cause the<br />
187
# filter to be placed *before* mod_deflate in the filter<br />
188
# chain. Giving it a numeric value slightly higher than<br />
189
# AP_FTYPE_CONTENT_SET will ensure that it is placed<br />
190
# after mod_deflate.<br />
191
ExtFilterDefine traceafter \<br />
192
<span class="indent">
193
cmd="/bin/tracefilter.pl /tmp/traceafter" \<br />
194
EnableEnv=trace_this_client ftype=21<br />
197
<Directory /usr/local/docs><br />
198
<span class="indent">
199
SetEnvIf Remote_Addr 192.168.1.31 trace_this_client<br />
200
SetOutputFilter tracebefore;deflate;traceafter<br />
205
<div class="example"><h3>Here is the filter which traces the data:</h3><p><code>
206
#!/usr/local/bin/perl -w<br />
209
open(SAVE, ">$ARGV[0]")<br />
210
<span class="indent">
211
or die "can't open $ARGV[0]: $?";<br />
214
while (<STDIN>) {<br />
215
<span class="indent">
225
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
226
<div class="directive-section"><h2><a name="ExtFilterDefine" id="ExtFilterDefine">ExtFilterDefine</a> <a name="extfilterdefine" id="extfilterdefine">Directive</a></h2>
227
<table class="directive">
228
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Define an external filter</td></tr>
229
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ExtFilterDefine <var>filtername</var> <var>parameters</var></code></td></tr>
230
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
231
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
232
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_ext_filter</td></tr>
234
<p>The <code class="directive">ExtFilterDefine</code> directive defines the
235
characteristics of an external filter, including the program to
236
run and its arguments.</p>
238
<p><var>filtername</var> specifies the name of the filter being
239
defined. This name can then be used in <code class="directive"><a href="../mod/core.html#setoutputfilter">SetOutputFilter</a></code>
240
directives. It must be unique among all registered filters.
241
<em>At the present time, no error is reported by the
242
register-filter API, so a problem with duplicate names isn't
243
reported to the user.</em></p>
245
<p>Subsequent parameters can appear in any order and define the
246
external command to run and certain other characteristics. The
247
only required parameter is <code>cmd=</code>. These parameters
251
<dt><code>cmd=<var>cmdline</var></code></dt>
253
<dd>The <code>cmd=</code> keyword allows you to specify the
254
external command to run. If there are arguments after the
255
program name, the command line should be surrounded in
256
quotation marks (<em>e.g.</em>, <code>cmd="<var>/bin/mypgm</var>
257
<var>arg1</var> <var>arg2</var>"</code>.) Normal shell quoting is
258
not necessary since the program is run directly, bypassing the shell.
259
Program arguments are blank-delimited. A backslash can be used to
260
escape blanks which should be part of a program argument. Any
261
backslashes which are part of the argument must be escaped with
262
backslash themselves. In addition to the standard CGI environment
263
variables, DOCUMENT_URI, DOCUMENT_PATH_INFO, and
264
QUERY_STRING_UNESCAPED will also be set for the program.</dd>
266
<dt><code>mode=<var>mode</var></code></dt>
268
<dd>Use <code>mode=output</code> (the default) for filters which
269
process the response. Use <code>mode=input</code> for filters
270
which process the request. <code>mode=input</code> is available
271
in Apache 2.1 and later.</dd>
273
<dt><code>intype=<var>imt</var></code></dt>
275
<dd>This parameter specifies the internet media type (<em>i.e.</em>,
276
MIME type) of documents which should be filtered. By default,
277
all documents are filtered. If <code>intype=</code> is
278
specified, the filter will be disabled for documents of other
281
<dt><code>outtype=<var>imt</var></code></dt>
283
<dd>This parameter specifies the internet media type (<em>i.e.</em>,
284
MIME type) of filtered documents. It is useful when the
285
filter changes the internet media type as part of the
286
filtering operation. By default, the internet media type is
289
<dt><code>PreservesContentLength</code></dt>
291
<dd>The <code>PreservesContentLength</code> keyword specifies
292
that the filter preserves the content length. This is not the
293
default, as most filters change the content length. In the
294
event that the filter doesn't modify the length, this keyword
295
should be specified.</dd>
297
<dt><code>ftype=<var>filtertype</var></code></dt>
299
<dd>This parameter specifies the numeric value for filter type
300
that the filter should be registered as. The default value,
301
AP_FTYPE_RESOURCE, is sufficient in most cases. If the filter
302
needs to operate at a different point in the filter chain than
303
resource filters, then this parameter will be necessary. See
304
the AP_FTYPE_foo definitions in util_filter.h for appropriate
307
<dt><code>disableenv=<var>env</var></code></dt>
309
<dd>This parameter specifies the name of an environment variable
310
which, if set, will disable the filter.</dd>
312
<dt><code>enableenv=<var>env</var></code></dt>
314
<dd>This parameter specifies the name of an environment variable
315
which must be set, or the filter will be disabled.</dd>
319
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
320
<div class="directive-section"><h2><a name="ExtFilterOptions" id="ExtFilterOptions">ExtFilterOptions</a> <a name="extfilteroptions" id="extfilteroptions">Directive</a></h2>
321
<table class="directive">
322
<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>
323
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ExtFilterOptions <var>option</var> [<var>option</var>] ...</code></td></tr>
324
<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>ExtFilterOptions DebugLevel=0 NoLogStderr</code></td></tr>
325
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory</td></tr>
326
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
327
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_ext_filter</td></tr>
329
<p>The <code class="directive">ExtFilterOptions</code> directive specifies
330
special processing options for <code class="module"><a href="../mod/mod_ext_filter.html">mod_ext_filter</a></code>.
331
<var>Option</var> can be one of</p>
334
<dt><code>DebugLevel=<var>n</var></code></dt>
337
The <code>DebugLevel</code> keyword allows you to specify
338
the level of debug messages generated by
339
<code class="module"><a href="../mod/mod_ext_filter.html">mod_ext_filter</a></code>. By default, no debug messages
340
are generated. This is equivalent to
341
<code>DebugLevel=0</code>. With higher numbers, more debug
342
messages are generated, and server performance will be
343
degraded. The actual meanings of the numeric values are
344
described with the definitions of the DBGLVL_ constants
345
near the beginning of <code>mod_ext_filter.c</code>.
347
<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
348
be stored in the Apache error log.</p>
351
<dt><code>LogStderr | NoLogStderr</code></dt>
353
<dd>The <code>LogStderr</code> keyword specifies that
354
messages written to standard error by the external filter
355
program will be saved in the Apache error log.
356
<code>NoLogStderr</code> disables this feature.</dd>
359
<div class="example"><h3>Example</h3><p><code>
360
ExtFilterOptions LogStderr DebugLevel=0
363
<p>Messages written to the filter's standard error will be stored
364
in the Apache error log. No debug messages will be generated by
365
<code class="module"><a href="../mod/mod_ext_filter.html">mod_ext_filter</a></code>. </p>
369
<div class="bottomlang">
370
<p><span>Available Languages: </span><a href="../en/mod/mod_ext_filter.html" title="English"> en </a> |
371
<a href="../ja/mod/mod_ext_filter.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
372
<a href="../ko/mod/mod_ext_filter.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
373
</div><div id="footer">
374
<p class="apache">Copyright 2006 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>
375
<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>
b'\\ No newline at end of file'