YuriM Posted January 21, 2008 Share Posted January 21, 2008 Hi. I have 90-99% CPU when trying to download file by using this code. And after debugging the code Ive found that CPU overload happens on the 'echo $result;' row. Class uses fsockopen function to get a file and returns data binary string. On the other side if I put file on the server and trying to download it I have no trouble with CPU overload. Here is the part of code. $http = new HttpClient(SERVICE_ADDRESS, SERVICE_PORT); $http->get( $parts['path'].'?'.$parts['query'] ); $result = $http->getContent(); header('Content-Type: '.$mime ); header('Content-Disposition: attachment; filename="'.$filename.'"' ); header('Content-Length: '.strlen( $result ) ); echo $result; // This string kills CPU exit(); As I've said I dont understand WHY echo on string I got from thet overload CPU. If someone can explain me what may be happens and what have I do. Link to comment https://forums.phpfreaks.com/topic/87029-have-a-cpu-overload-when-trying-to-get-file-from-apache/ Share on other sites More sharing options...
Lumio Posted January 21, 2008 Share Posted January 21, 2008 Hi! Maybe it's better to use fopen and fgets Link to comment https://forums.phpfreaks.com/topic/87029-have-a-cpu-overload-when-trying-to-get-file-from-apache/#findComment-445074 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.