lighttpd mod_cgi从脚本设置http错误

问题描述 投票:0回答:1

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-script转换为400 Bad request

cgi lighttpd
1个回答
0
投票

脚本应始终返回0。要设置HTTP状态,请使用下一种方法。

#!/bin/sh

echo "Status: 400 Bad request"; echo
echo "message"

更多有关CGI的示例和信息在wikipedia上>

© www.soinside.com 2019 - 2024. All rights reserved.