LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1098|回复: 1

perl http协议??

[复制链接]
发表于 2007-5-9 20:21:54 | 显示全部楼层 |阅读模式
#!perl

print << "EOF" ;
Content-type: text/html

<HTML>
<HEAD>
<TITLE>CGI</TITLE>
<BODY>
Hello CGI!
</BODY>
EOF
http://localhost:8080/cgi-bin/hello2.cgi
Hello CGI!
一个需留意的是在Content-type: text/html与<HTML>中是必须空一行的,
否则如下会
#!perl

print << "EOF" ;
Content-type: text/html
<HTML>
<HEAD>
<TITLE>CGI</TITLE>
<BODY>
Hello CGI!
</BODY>
EOF
http://localhost:8080/cgi-bin/hello2.cgi
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@domain and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

就这一行我足足找了好久,为什么。
(现在在win下别BS我了,我是用Linux的)
发表于 2007-5-11 21:14:56 | 显示全部楼层
这是规定!!
因为HTML文本输出时,要知道文件类型。也就是content-type: text/html
后面要两个回车。不然出错。(分析文件头时会检查这个,格式不对就出错。)
__END__
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表