curl-and-php
Bad response
Date: Sat, 28 Apr 2012 16:23:28 +0200
Hello,
I have a problem with content downloaded by curl, sometimes it's
downloaded partially.
I have a proxy between server and curl, and seems that all size is
delivered.
But "size_download" differs of "Content-Length".
Perhaps I am using some function in wrong manner....
Any suggestion?
$maxth = 3;
$channel=1;
$ch=array();
$running=0;
$mcurl = curl_multi_init();
...
(this is a loop) {
$acch= count($ch);
$xmlstr=null;
if ($acch > $maxth){
$cl = ($channel - $maxth);
$info=array();
while($xmlstr=== null || $xmlstr=== false /*||
$info["download_content_length"]!=$info["size_download"]*/){
$info=curl_getinfo($ch[$cl]['curl']);
if (!empty($info['total_time'])){
if($info['http_code'] != 200) {
print("Bad Response {$info['http_code']}\n");
break;
}
}
$xmlstr=curl_multi_getcontent($ch[$cl]['curl']);
curl_multi_select($mcurl);
}
(bad response continue loop)
..
(do something with content $xmlstr, but sometimes it's corrupted)
..
}
...
$ch[$channel]['curl'] = curl_init();
curl_setopt_array($ch[$channel]['curl'], $curloptarray);
curl_setopt($ch[$channel]['curl'], CURLOPT_URL, $url);
curl_multi_add_handle($mcurl,$ch[$channel]['curl']);
$channel++;
if ($total-$i < $maxth) $maxth = 0;
do {
curl_multi_exec($mcurl,$running);
curl_multi_select($mcurl);
} while ($running > $maxth - 1);
}
-- -- http://www.0pc.eu/ _______________________________________________ http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-phpReceived on 2012-04-29