我有这个简单的CGI脚本(我编译):
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("Content-Type: text/plain\n\nHello world!\n");
for(register unsigned short i=argc; i>0;) {
--i; printf("argv[%d]=%s ", i, argv[i]);
}
}
但我无法弄清楚如何获取任何标题信息。
以下是我对默认lighttpd.conf
所做的差异:
server.modules = ("mod_access", "mod_accesslog", "mod_alias",
"mod_cgi", "mod_compress", "mod_status", )
server.port = 8000
#### CGI module
$HTTP["url"] =~ "/cgi-bin/" {
cgi.assign = ( "" => "" )
}
cgi.assign = ( ".cgi" => "")
答案 0 :(得分:1)
@ Stefan的链接都破了,所以决定写下我从研究中找到的答案:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
printf("Content-Type: text/plain\n\nHello world!\n");
const char *method_str = getenv("REQUEST_METHOD");
for(register unsigned short i=argc; i>0;) {
--i; printf("argv[%d]=%s ", i, argv[i]);
}
printf("REQUEST_METHOD = %s", method_str);
}
答案 1 :(得分:0)