请教个C语言的cgi问题

h_falls 2003-07-03 01:38:04
int main(void)
{
//printf("HTTP/1.1 200 OK\r\n");
printf("Content-Disposition: inline; filename=t.m3u\r\n");
printf("Connection: close\r\n");
printf("Transfer-Encoding: chunked\r\n");
printf("Content-Type: audio/x-mpegurl\r\n\r\n");
printf("http://192.168.10.12/t.mp3");

return 0;
}
一个非常简单的cgi,但在浏览器里访问就出错
请问怎么回事?
...全文
44 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
fujunlin 2003-12-05
  • 打赏
  • 举报
回复
oh yse...
艾伦说的很好 /n/n,一定要。。
我测试成功了。
demon007 2003-11-06
  • 打赏
  • 举报
回复
gz
ykj76 2003-10-21
  • 打赏
  • 举报
回复
我想你是想在线播放吧.
注意要有t.m3u和t.mp3.
int main(void)
{
printf("Content-Disposition: inline; filename=t.m3u\r\n");
printf("Content-Type: audio/x-mpegurl\r\n\r\n");
printf("http://192.168.10.12/t.mp3");
return 0;
}
CGI程序传送到浏览器端的M3U必须和MP3播放器建立关联。建立关联的方法是在Winamp菜单中选择"Options"-"Preferences"-"File Type Setup"中选中"MP3"和"M3U",然后选择"Apply"按钮将其关联注册到系统中。首次执行此CGI时,应选择"在当前位置打开"t.m3u文件,并清除"在打开这种类型的文件前始终询问"选择,则以后播放时就没有此"如何处理该文件"提示了。
wulemale 2003-10-20
  • 打赏
  • 举报
回复
szAlanLiao:
既然输出的MIME类型是HTML,程序中的\n就要换成<br>了,否则就没有换行作用了。
szAlanLiao 2003-09-07
  • 打赏
  • 举报
回复
我说的是\n\n一定要

看看可有借鉴的??
int main(int argc, char* argv[])
{
printf("Content-Type: text/html\n\n");//一定要空行
printf("<html>\r\n");
printf("<body bgcolor=\"#ffffff\">\r\n");
printf("<title>Welcome to NTOU CC Email/WWW Server</title>\r\n");
printf("......\r\n");
printf("</body>\r\n");
printf("</html>\r\n");
return 0;
}
zhaoweikid 2003-09-06
  • 打赏
  • 举报
回复
那个到是一定要,不然会有"Premature end of script headers"的错误。
zhaoweikid 2003-09-06
  • 打赏
  • 举报
回复
你在C里空行没有用啊,编译器会忽略空行的。。。。。。。。。

只是在返回的页面里的header之后的空行表示header结束。。
zhaoweikid 2003-09-06
  • 打赏
  • 举报
回复
你在C里空行没有用啊,编译程序里当然
googleboy 2003-09-05
  • 打赏
  • 举报
回复
那个空行没有必要吧??错!!!!!!!!!!!!
一定要的!
zf_fcxp 2003-09-04
  • 打赏
  • 举报
回复
int main(void)
{
printf("Content-type: text/html\n\n");
printf("hello\n");
return 0;
}
你要说清楚他提示的是什么错误.
zhaoweikid 2003-09-04
  • 打赏
  • 举报
回复
那个空行没有必要吧??
szAlanLiao 2003-09-04
  • 打赏
  • 举报
回复
看看可有借鉴的??
int main(int argc, char* argv[])
{
printf("Content-Type: text/html\n\n");//一定要空行

printf("<html>\r\n");
printf("<body bgcolor=\"#ffffff\">\r\n");
printf("<title>Welcome to NTOU CC Email/WWW Server</title>\r\n");
printf("......\r\n");
printf("</body>\r\n");
printf("</html>\r\n");

return 0;
}

2,203

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 CGI
社区管理员
  • CGI社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧