apache / 2.4 / reference / mod-mod_asis.html

Apache 模块 mod_asis

Description: 发送包含其自己的 HTTP Headers 的文件
Status: Base
Module Identifier: asis_module
Source File: mod_asis.c

Summary

该模块提供处理程序send-as-is,该处理程序使 Apache HTTP Server 发送文档而无需添加大多数常用的 HTTP Headers。

这可用于从服务器发送任何类型的数据,包括重定向和其他特殊的 HTTP 响应,而无需 cgi-script 或 nph 脚本。

由于历史原因,此模块还将处理 MIME 类型为httpd/send-as-is的任何文件。

Usage

在服务器配置文件中,将文件与send-as-is处理程序相关联例如

AddHandler send-as-is asis

然后,具有 httpextensions 的任何文件的内容都将由 Apache httpd 发送到 Client 端,几乎没有任何更改。特别是,HTTP 头是根据mod_cgi规则从文件本身派生的,因此 asis 文件必须包含有效的头,并且还可以使用 CGI Status:头来确定 HTTP 响应代码。 Content-Length:Headers 将自动插入,或者(如果包含的话)由 httpd 更正。

这是一个文件的示例,其内容按“原样”发送,以告知 Client 端文件已重定向。

Status: 301 Now where did I leave that URL Location: http://xyz.example.com/foo/bar.html Content-type: text/html <html> <head> <title>Lame excuses'R'us</title> </head> <body> <h1>Fred's exceptionally wonderful page has moved to <a href="http://xyz.example.com/foo/bar.html">Joe's</a> site. </h1> </body> </html>

Notes:

服务器始终向返回给 Client 端的数据添加Date:Server:Headers,因此这些不应包含在文件中。服务器添加Last-ModifiedHeaders;它可能应该。