switch to a 60 bit hash
[httpd-crcsyncproxy.git] / docs / manual / mod / mod_sed.xml
blobb414589685cdb643ff739fdb5e41d3e3b61ecef1
1 <?xml version="1.0"?>
2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
6 <!--
7  Licensed to the Apache Software Foundation (ASF) under one or more
8  contributor license agreements.  See the NOTICE file distributed with
9  this work for additional information regarding copyright ownership.
10  The ASF licenses this file to You under the Apache License, Version 2.0
11  (the "License"); you may not use this file except in compliance with
12  the License.  You may obtain a copy of the License at
14      http://www.apache.org/licenses/LICENSE-2.0
16  Unless required by applicable law or agreed to in writing, software
17  distributed under the License is distributed on an "AS IS" BASIS,
18  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and
20  limitations under the License.
21 -->
23 <modulesynopsis metafile="mod_sed.xml.meta">
25 <name>mod_sed</name>
26 <description>Filter Input (request) and Output (response) content using <code>sed</code> syntax</description>
27 <status>Experimental</status>
28 <sourcefile>mod_sed.c sed0.c sed1.c regexp.c regexp.h sed.h</sourcefile>
29 <identifier>sed_module</identifier>
30 <compatibility>Available in Apache 2.3 and later</compatibility>
32 <summary>
33 <p>
34 <module>mod_sed</module> is an in-process content filter. The <module>mod_sed</module> filter implements the <code>sed</code> editing
35 commands implemented by the Solaris 10 <code>sed</code>
36 program as described in the <a href="http://docs.sun.com/app/docs/doc/816-5165/sed-1b?a=view">manual
37 page</a>. However, unlike <code>sed</code>, <module>mod_sed</module> doesn't take data from
38 standard
39 input. Instead, the filter acts on the entity data sent between client and
40 server. <module>mod_sed</module> can be used as an input or output filter. <module>mod_sed</module> is a
41 content filter, which means that it cannot be used to modify client or
42 server http headers.
43 </p>
44 <p>
45 The <module>mod_sed</module> output filter accepts a chunk of data, executes the <code>sed</code> scripts on the data, and generates the output which is passed to the next filter in the chain.
46 </p>
48 <p>
49 The <module>mod_sed</module> input filter reads the data from the next filter in the chain, executes the <code>sed</code> scripts, and returns the generated data to the caller filter in the filter chain.
50 </p>
52 <p>
53 Both the input and output filters only process the data if newline characters are seen in the content. At the end of the data, the rest of the data is treated as the last line.
54 </p>
56 <p>A tutorial article on <module>mod_sed</module>, and why it is more powerful than simple
57 string or regular expression search and replace, is available <a
58 href="http://blogs.sun.com/basant/entry/using_mod_sed_to_filter">on
59 the author's blog</a>.</p>
61 </summary>
63 <section id="sampleconf"><title>Sample Configuration</title>
64     <example><title>Adding an output filter </title>
65          # In the following example, the sed filter will change the string<br />
66          # "monday" to "MON" and the string "sunday" to SUN in html documents<br />
67          # before sending to the client.<br />
68         <indent>
69         &lt;Directory "/var/www/docs/sed"&gt; <br />
70            <indent>
71            AddOutputFilter Sed html <br />
72            OutputSed "s/monday/MON/g" <br />
73            OutputSed "s/sunday/SUN/g" <br />
74            </indent>
75         &lt;/Directory&gt; <br />
76         </indent>
77     </example>
79     <example><title>Adding an input filter </title>
80          # In the following example, the sed filter will change the string<br />
81          # "monday" to "MON" and the string "sunday" to SUN in the POST data<br />
82          # sent to PHP.<br />
83         <indent>
84         &lt;Directory "/var/www/docs/sed"&gt; <br />
85            <indent>
86            AddInputFilter Sed php <br />
87            InputSed "s/monday/MON/g" <br />
88            InputSed "s/sunday/SUN/g" <br />
89            </indent>
90         &lt;/Directory&gt; <br />
91         </indent>
92     </example>
93 </section>
94 <section id="sed_commands"><title>Sed Commands</title>
95     <p>
96     Complete details of the <code>sed</code> command can be found from the
97    <a href="http://docs.sun.com/app/docs/doc/816-5165/sed-1b?a=view">sed manual
98 page</a>.
99     </p>
100     <dl>
101         <dt><code>b</code></dt>
102         <dd>Branch to the label specified (similar to goto).</dd>
103         <dt><code>h</code></dt>
104         <dd>Copy the current line to the hold buffer.</dd>
105         <dt><code>H</code></dt>
106         <dd>Append the current line to the hold buffer.</dd>
107         <dt><code>g</code></dt>
108         <dd>Copy the hold buffer to the current line.</dd>
109         <dt><code>G</code></dt>
110         <dd>Append the hold buffer to the current line.</dd>
111         <dt><code>x</code></dt>
112         <dd>Swap the contents of the hold buffer and the current line.</dd>
113     </dl>
114 </section>
116 <directivesynopsis>
117 <name>OutputSed</name>
118 <description>Sed command for filtering response content</description>
119 <syntax>OutputSed <var>sed-command</var></syntax>
120 <contextlist><context>directory</context><context>.htaccess</context>
121 </contextlist>
123 <usage>
124     <p>The <directive>OutputSed</directive> directive specifies the <code>sed</code>
125     command to execute on the response.
126     </p>
127 </usage>
128 </directivesynopsis>
130 <directivesynopsis>
131 <name>InputSed</name>
132 <description>Sed command to filter request data (typically <code>POST</code> data)</description>
133 <syntax>InputSed <var>sed-command</var></syntax>
134 <contextlist><context>directory</context><context>.htaccess</context>
135 </contextlist>
137 <usage>
138     <p>The <directive>InputSed</directive> directive specifies the <code>sed</code> command
139     to execute on the request data e.g., <code>POST</code> data.
140     </p>
141 </usage>
142 </directivesynopsis>
144 </modulesynopsis>