?????? 前些陣子因?yàn)樽霎厴I(yè)設(shè)計(jì)的需要,需要一個(gè)用到BOA,主要是通過其向用戶提供一個(gè)設(shè)置的界面,然后通過cgi設(shè)置,我的這個(gè)cgi必須要用C實(shí)現(xiàn),在cgi時(shí)遇到很多困難,因?yàn)槲乙郧耙矎膩頉]有寫過cgi程序,對(duì)BOA也不熟,當(dāng)我用里面的示例時(shí),那個(gè)用perl寫的cgi能正常運(yùn)行,而我自己寫的C程序卻總是出現(xiàn)錯(cuò)誤,我寫的是一般的打印出一條語句而已,并沒有按照HTTP協(xié)議標(biāo)準(zhǔn)輸出其它的信息。因而老是出現(xiàn)502 bad gateway? The CGI was not CGI/1.1 compliant. 錯(cuò)誤,這里給出我自已寫的一個(gè)通過的測(cè)試代碼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>");
}