ID: 49838
Updated by: [email protected]
Reported By: travian dot utils at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: Sockets related
Operating System: FreeBSD 7.2-RELEASE-p4 amd64
PHP Version: 5.2.11
New Comment:
Thank you for your bug report.
I don't understand the description you gave. Please make a small PHP
script to reproduce the problem and describe what the expected and
actual output are. Also, please explain exactly what is going wrong in
which PHP function.
Previous Comments:
------------------------------------------------------------------------
[2009-10-11 17:13:45] travian dot utils at gmail dot com
Corrected summary.
------------------------------------------------------------------------
[2009-10-11 17:08:44] travian dot utils at gmail dot com
Description:
------------
feof() reached end of stream while reading big HTTP response from
socket using fgets.
Reproduce code:
---------------
...
$fp = @fsockopen ($sname, 80, $errno, $errstr, 18);
if ($fp) {
fputs ($fp, "GET /".$xxx." HTTP/1.0\r\nHost:
".$sname."\r\nUser-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0;
en-US; rv:1.9.0.2) Gecko/2008092313 Firefox/3.1.6\r\n\r\n");
$time='';
$len='';
$substr='';
$upstr='';
$redirect='';
$http_code=0;
while (!feof($fp)) {
$line=fgets($fp,256);
$substr=substr($line,0,15);
$substr2=substr($line,0,10);
$substr3=substr($line,0,16);
if(strpos($line, '404 Not Found')!=false){$http_code=404;
break;};
if($line==chr(13).chr(10))break;
if($substr2=='Location: '){$redirect=substr($line,10);break;};
if($substr3=='Content-Length: ')$len=intval(substr($line,16));
if($substr=='Last-Modified: ')$time=substr($line,15);
}
$rlen=0;
unset($lines);
// This cycle reached end while reading big HTTP response
while (!feof($fp)) {
$line=fgets($fp,1024);
$lines[]=$line;
$rlen+=strlen($line);
}
//print('$len='.$len);
//print('$time='.$time);
$dtin=date('Y-m-d',strtotime($time));
$time=strtotime($time);
//print('$dtin='.$dtin);
//print('$time='.$time);
if($http_code==404){
return -10;
}elseif($dtin==$dt){
return -2;
}elseif($time==-1){
return -3;
}elseif($redirect!=''){
return -4;
}elseif($time==''){
return -5;
}elseif(isset($timein)){
if($time<=$timein){
return 0;
}
}
}else{
return -6;
}
...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49838&edit=1