#24376 [Opn->Bgs]: fgets fread can't read long date in fsockopen
| From: | wez@php.net | Date: | Sat, 28 Jun 2003 18:00:19 +0000 |
| Subject: | #24376 [Opn->Bgs]: fgets fread can't read long date in fsockopen | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-42680@lists.php.net to get a copy of this message | ||
ID: 24376
Updated by: wez@php.net
Reported By: sanry at now dot net dot cn
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: redhat8
PHP Version: 4.3.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Please read the documentation for fread():
http://www.php.net/manual/en/function.fread.php
Note: When reading from network streams or pipes, such as those
returned when reading remote files or from popen() and proc_open(),
reading will stop after a packet is available. This means that you
should collect the data together in chunks as shown in the example
below.
Your script worked in 4.3.1 because of a bug in that version.
Previous Comments:
------------------------------------------------------------------------
[2003-06-28 12:54:55] sanry at now dot net dot cn
Description:
------------
fgets fread can't read long date in fsockopen
php4.3.2 ever can't use any remote file function
php4.3.1 everything is okay
whatever $len is set , it can't read any long date
but everything is okay in php4.3.1 or older
there are so many big problem with remote file function
in php4.3.2 .
I post this bug for twice , I am not kitting .
function remote_request($host,
$path,$port=80,$method="GET",$len=2048,$user="",$pass="") {
$agent="Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)";
$fp = fsockopen($host,$port,$errno, $errstr, 6);
socket_set_timeout($fp, 18);
if (!$fp) {
echo "$err_msg ($err_num)<br>\n";
} else {
$auth = $user.":".$pass ;
$string=base64_encode($auth);
fputs($fp,"$method $path HTTP/1.1 \r\n");
fputs($fp,"Host: $host \r\n");
fputs($fp,"Accept-Language: zh-cn \r\n");
//fputs($fp,"charset=GBK");
if($pass)fputs($fp, "Authorization: Basic
".$string."\r\n");
fputs($fp, "User-Agent: ".$agent."\r\n");
if($pass)fputs($fp, "Content-type:
application/x-www-form-urlencoded \r\n");
//fputs($fp, "Cache-Control: no-cache\r\n");
fputs($fp, "Connection: close\r\n");
fputs($fp, "\r\n");
$reply=fread($fp,$len);
fclose($fp);
}
return $reply;
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24376&edit=1