Apache HTTP Server 版本 2.4

| 描述 | 使用 sed 语法过滤输入(请求)和输出(响应)内容 |
|---|---|
| 状态 | 实验性 |
| 模块标识符 | sed_module |
| 源文件 | mod_sed.c sed0.c sed1.c regexp.c regexp.h sed.h |
| 兼容性 | 在 Apache 2.3 及更高版本中可用 |
mod_sed 是一个进程内内容过滤器。 mod_sed 过滤器实现了由 Solaris 10 sed 程序实现的 sed 编辑命令,如 手册页 中所述。但是,与 sed 不同,mod_sed 不会从标准输入获取数据。相反,过滤器作用于客户端和服务器之间发送的实体数据。 mod_sed 可用作输入或输出过滤器。 mod_sed 是一个内容过滤器,这意味着它不能用于修改客户端或服务器 http 标头。
mod_sed 输出过滤器接受一段数据,对数据执行 sed 脚本,并生成传递给链中下一个过滤器的输出。
mod_sed 输入过滤器从链中下一个过滤器读取数据,执行 sed 脚本,并将生成的数据返回给过滤器链中的调用者过滤器。
输入和输出过滤器仅在内容中看到换行符时才处理数据。在数据结束时,其余数据被视为最后一行。在 2.4.54 及更高版本中,长度超过 8MB 的行会导致错误。
# 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>
# 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 命令的完整详细信息,请参阅 sed 手册页。
bhHgGx