| <?xml version="1.0"?> |
| <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd"> |
| <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?> |
| <!-- $LastChangedRevision$ --> |
| |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <modulesynopsis metafile="mod_sed.xml.meta"> |
| |
| <name>mod_sed</name> |
| <description>Filter Input (request) and Output (response) content using <code>sed</code> syntax</description> |
| <status>Experimental</status> |
| <sourcefile>mod_sed.c sed0.c sed1.c regexp.c regexp.h sed.h</sourcefile> |
| <identifier>sed_module</identifier> |
| <compatibility>Available in Apache 2.3 and later</compatibility> |
| |
| <summary> |
| <p> |
| <module>mod_sed</module> is an in-process content filter. The <module>mod_sed</module> filter implements the <code>sed</code> editing |
| commands implemented by the Solaris 10 <code>sed</code> |
| program as described in the <a href="http://www.gnu.org/software/sed/manual/sed.txt">manual |
| page</a>. However, unlike <code>sed</code>, <module>mod_sed</module> doesn't take data from |
| standard |
| input. Instead, the filter acts on the entity data sent between client and |
| server. <module>mod_sed</module> can be used as an input or output filter. <module>mod_sed</module> is a |
| content filter, which means that it cannot be used to modify client or |
| server http headers. |
| </p> |
| <p> |
| 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. |
| </p> |
| |
| <p> |
| 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. |
| </p> |
| |
| <p> |
| 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. |
| </p> |
| |
| </summary> |
| |
| <section id="sampleconf"><title>Sample Configuration</title> |
| <example><title>Adding an output filter </title> |
| <highlight language="config"> |
| # In the following example, the sed filter will change the string |
| # "monday" to "MON" and the string "sunday" to SUN in html documents |
| # before sending to the client. |
| <Directory "/var/www/docs/sed"> |
| AddOutputFilter Sed html |
| OutputSed "s/monday/MON/g" |
| OutputSed "s/sunday/SUN/g" |
| </Directory> |
| </highlight> |
| </example> |
| |
| <example><title>Adding an input filter </title> |
| <highlight language="config"> |
| # In the following example, the sed filter will change the string |
| # "monday" to "MON" and the string "sunday" to SUN in the POST data |
| # sent to PHP. |
| <Directory "/var/www/docs/sed"> |
| AddInputFilter Sed php |
| InputSed "s/monday/MON/g" |
| InputSed "s/sunday/SUN/g" |
| </Directory> |
| </highlight> |
| </example> |
| </section> |
| <section id="sed_commands"><title>Sed Commands</title> |
| <p> |
| Complete details of the <code>sed</code> command can be found from the |
| <a href="http://www.gnu.org/software/sed/manual/sed.txt">sed manual |
| page</a>. |
| </p> |
| <dl> |
| <dt><code>b</code></dt> |
| <dd>Branch to the label specified (similar to goto).</dd> |
| <dt><code>h</code></dt> |
| <dd>Copy the current line to the hold buffer.</dd> |
| <dt><code>H</code></dt> |
| <dd>Append the current line to the hold buffer.</dd> |
| <dt><code>g</code></dt> |
| <dd>Copy the hold buffer to the current line.</dd> |
| <dt><code>G</code></dt> |
| <dd>Append the hold buffer to the current line.</dd> |
| <dt><code>x</code></dt> |
| <dd>Swap the contents of the hold buffer and the current line.</dd> |
| </dl> |
| </section> |
| |
| <directivesynopsis> |
| <name>OutputSed</name> |
| <description>Sed command for filtering response content</description> |
| <syntax>OutputSed <var>sed-command</var></syntax> |
| <contextlist><context>directory</context><context>.htaccess</context> |
| </contextlist> |
| |
| <usage> |
| <p>The <directive>OutputSed</directive> directive specifies the <code>sed</code> |
| command to execute on the response. |
| </p> |
| </usage> |
| </directivesynopsis> |
| |
| <directivesynopsis> |
| <name>InputSed</name> |
| <description>Sed command to filter request data (typically <code>POST</code> data)</description> |
| <syntax>InputSed <var>sed-command</var></syntax> |
| <contextlist><context>directory</context><context>.htaccess</context> |
| </contextlist> |
| |
| <usage> |
| <p>The <directive>InputSed</directive> directive specifies the <code>sed</code> command |
| to execute on the request data e.g., <code>POST</code> data. |
| </p> |
| </usage> |
| </directivesynopsis> |
| |
| </modulesynopsis> |