前些阵子因为做毕业设计的需要,需要一个用到BOA,主要是通过其向用户提供一个设置的界面,然后通过cgi设置,我的这个cgi必须要用C实现,在cgi时遇到很多困难,因为我以前也从来没有写过cgi程序,对BOA也不熟,当我用里面的示例时,那个用perl写的cgi能正常运行,而我自己写的C程序却总是出现错误,我写的是一般的打印出一条语句而已,并没有按照HTTP协议标准输出其它的信息。因而老是出现502 bad gateway  The CGI was not CGI/1.1 compliant. 错误,这里给出我自已写的一个通过的测试代码test.c
#include <stdio.h>
#include <unistd.h>
		void main()
{
        printf("Content-type: text/html\n");
        printf("\n");
        printf("<html><head><title>CGI TEST</title></head>");
        printf("<body>");
        printf("<h1>BOA CGI TEST</h1>");
        printf("<h2>huyi</h2>");
        printf("Hello\n");
        printf("</body></html>");
}