lighttpd mod_cgi 从脚本设置 http 错误
lighttpd mod_cgi set http error from script
lighttpd mod_cgi配置如下
server.modules += ( "mod_cgi", "mod_alias", "mod_setenv" )
cgi.assign += ( "" => "" ) ## run exectables with shebang
$HTTP["url"] == "network" {
$HTTP["request-method"] == "GET" {
alias.url += ( "network" => "/usr/bin/network" )
setenv.add-response-header = ( "Content-Type" => "application/xml" )
}
}
当文件 /usr/bin/network
返回错误时,lighttpd 以 500 Internal server error
.
响应客户端
如何处理该错误并将其从 cgi 脚本转换为 400 Bad request
?
脚本应始终 return 0。要设置 HTTP 状态,请使用下一种方法。
#!/bin/sh
echo "Status: 400 Bad request"; echo
echo "message"
有关 CGI 的更多示例和信息在 wikipedia
lighttpd mod_cgi配置如下
server.modules += ( "mod_cgi", "mod_alias", "mod_setenv" )
cgi.assign += ( "" => "" ) ## run exectables with shebang
$HTTP["url"] == "network" {
$HTTP["request-method"] == "GET" {
alias.url += ( "network" => "/usr/bin/network" )
setenv.add-response-header = ( "Content-Type" => "application/xml" )
}
}
当文件 /usr/bin/network
返回错误时,lighttpd 以 500 Internal server error
.
如何处理该错误并将其从 cgi 脚本转换为 400 Bad request
?
脚本应始终 return 0。要设置 HTTP 状态,请使用下一种方法。
#!/bin/sh
echo "Status: 400 Bad request"; echo
echo "message"
有关 CGI 的更多示例和信息在 wikipedia