php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24376 fgets fread can't read long date in fsockopen
Submitted: 2003-06-28 12:54 UTC Modified: 2003-06-28 13:00 UTC
From: sanry at now dot net dot cn Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.3.2 OS: redhat8
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sanry at now dot net dot cn
New email:
PHP Version: OS:

 

 [2003-06-28 12:54 UTC] 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;
}



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-28 13:00 UTC] wez@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 01 01:01:28 2024 UTC