老夫费劲心机,苦学perl,终于解决了此问题,此文大概为目前互联网上唯一的解释(至少就我自己几天猛搜的结果看来!),
哈哈。不过昨天兴奋过度,唉,只好修正下这篇文章了!
author: bailing
time: 2007-03-07
modified: 2007-03-08
E: CGI.pm: Server closed socket during multipart read (client aborted?).
S: 发生在用MegaUpload上传文件时,但是传小文件(小于等于3706bytes,大概4KB附近)时,却正常执行下去了。
A: 原因从这里开始[upload.cgi]
open( STDIN , "$post_data_file" ) or die "can't open temp file";
my $cg = new CGI();
这里,将post_data_file作为默认的输入,CGI的read_from_client函数会从STDIN读取提交的http包,
然而对于 这里读到的,凡是\n均被复制了,所以包的长度不正确,结构数据也不正确,所以就会返回
malformed multipart POST 这个错误,因为STDIN默认是文本模式?我尝试用binmode STDIN;
无效。在open STDIN前加上 close( STDIN );天下太平
close( STDIN );
open( STDIN , "$post_data_file" ) or die "can't open temp file";
my $cg = new CGI();
以下代码保留,尽管解决方法错了,代码还是有留存的价值的。
print TMP "POST $ENV{'REQUEST_URI'} $ENV{'SERVER_PROTOCOL'}\r\n";
print TMP "Accept-Language: $ENV{'HTTP_ACCEPT_LANGUAGE'}\r\n";
print TMP "Content-Type: $ENV{'CONTENT_TYPE'}\r\n";
print TMP "User-Agent: $ENV{'HTTP_USER_AGENT'}\r\n";
print TMP "Host: $ENV{'HTTP_HOST'}\r\n";
print TMP "Content-Length: $ENV{'CONTENT_LENGTH'}\r\n";
print TMP "Connection: $ENV{'HTTP_CONNECTION'}\r\n";
print TMP "\r\n";
OA: http://www.globalmoxie.com/cgi-bin/forums/ultimatebb.cgi?ubb=get_topic;f=1;t=000451 这里说去掉
perl的-w参数就好了。 (呵呵,搞笑)
it means:
*CGI.pm and Perl v5.6.0 could not read a POSTed multipart stream satisfactorily producing the
error "CGI.pm: Server closed socket during multipart read (client aborted?)". This is apparently
a known problem fixed by migrating to Perl 5.6.1 (or later) and it's CGI.pm. *
这个人说5.6.1或更高版本的perl已经解决了这个问题,但是,我的是v5.8.8的[perl -version],CGI.pm也是最新的。
|
请发表评论