Apache 模块已修改
Description: | 使用sed 语法过滤 Importing(请求)和输出(响应)内容 |
---|---|
Status: | Experimental |
Module Identifier: | sed_module |
Source File: | mod_sed.c sed0.c sed1.c regexp.c regexp.h sed.h |
Compatibility: | 在 Apache 2.3 和更高版本中可用 |
Summary
mod_sed是一个进程内内容过滤器。 _过滤器实现由 Solaris 10 sed
程序实现的sed
编辑命令,如manual page中所述。但是,与sed
不同,mod_sed不会从标准 Importing 中获取数据。而是,筛选器作用于在 Client 端和服务器之间发送的实体数据。 mod_sed可用作 Importing 或输出滤波器。 mod_sed是内容过滤器,这意味着它不能用于修改 Client 端或服务器的 HTTP Headers。
mod_sed输出过滤器接受大量数据,对数据执行sed
脚本,并生成输出,该输出将传递到链中的下一个过滤器。
mod_sedImporting 过滤器从链中的下一个过滤器读取数据,执行sed
脚本,并将生成的数据返回到过滤器链中的调用方过滤器。
如果在内容中看到换行符,则 Importing 和输出过滤器都仅处理数据。在数据末尾,其余数据被视为最后一行。
Sample Configuration
添加输出过滤器
# 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>
添加 Importing 过滤器
# 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>
Sed Commands
可以从sed 手册页找到sed
命令的完整详细信息。
-
b
- 转到指定的标签(类似于 goto)。
-
h
- 将当前行复制到保持缓冲区。
-
H
- 将当前行追加到保持缓冲区。
-
g
- 将保持缓冲区复制到当前行。
-
G
- 将保持缓冲区追加到当前行。
-
x
- 交换保持缓冲区的内容和当前行。
InputSed Directive
Description: | sed 命令用于过滤请求数据(通常为POST 数据) |
---|---|
Syntax: | InputSed sed-command |
Context: | directory, .htaccess |
Status: | Experimental |
Module: | mod_sed |
InputSed
指令指定要对请求数据(例如POST
数据)执行的sed
命令。
OutputSed Directive
Description: | sed 命令,用于过滤响应内容 |
---|---|
Syntax: | OutputSed sed-command |
Context: | directory, .htaccess |
Status: | Experimental |
Module: | mod_sed |
OutputSed
指令指定对响应执行的sed
命令。