linux boa post方式失败,boa使用中常见的错误

1. 当运行boa程序时出现错误,如下: # ./boa [27/Nov/1990:13:22:25 + 0000]boa.c:266.icky Linux kernel bug!:No such file 将 User 0修改成 User nobody 2. 打开网页时,网页中的图片无法显示 就将存放图片的子目录/var/www/images修改成/var/www/img 3. 在测试cgi脚本时,当在浏览器地址中输入“http//10.10.10.2/cgi-bin/helloworld.cgi”时,浏览输出下述错误: 502 Bad Gateway The CGI was not CGI/1.1 compliant (注:此种错误在使用BOA时十分常见,原因基本都是自己写的cgi程序的输入输出问题) 在目标板的调试终端中输出下述错误: ……cgi_header:unable to find LFIF 上述错误是在boa原码中的cgi_header .c文件中的process_cgi_header函数产生,如下: buf = req->header_line; c = strstr(buf, "\n\r\n"); if (c == NULL) { c = strstr(buf, "\n\n"); if (c == NULL) { log_error_time(); fputs("cgi_header: unable to find LFLF\n", stderr); //出错信息 #ifdef FASCIST_LOGGING log_error_time(); fprintf(stderr, "\"%s\"\n", buf); #endif send_r_bad_gateway(req); return 0; } } 我们可以定义FASCIST_LOGGING,使产生该错误时将buf内容打印出来,结果如下: ……cgi_header:unable to find LFIF Content-type: text/html

CGI OutputHello, world. 原来buf中的内容就是helloworld.c中输出的内容,查看输出结果,再看process_cgi_header函数中的语句:c = strstr(buf, "\n\n"),很明显buf中没有两个连续的换行符"\n\n",所以是helloworld.c文件中的语句:printf("Content- type: text/html\n\n");错写成了printf("Content-type: text/html\n"); 上述行通过标准输出将字符串″Contenttype:text/plain\n\n″传送给Web服务器。它是一个MIME头信息,告诉Web服务器随后的输出是以纯ASCII文本的形式。在这个头信息中有两个新行符,这是因为Web服务器需要在实际的文本信息开始之前先看见一个空行。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值