?????? 前些陣子因為做畢業設計的需要,需要一個用到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>");
}