php5-curl is installed but curl_exec()
returns null
, curl_errno()
returns 0
, curl_error()
returns null
, curl_getinfo()
looks like curl_exec()
never fired.
Sample of code
$this->curl = curl_init();
$agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0';
$curlOptions = array(
CURLOPT_URL=>str_replace(' ', '%20', $url),
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_USERAGENT=>$agent,
CURLOPT_BINARYTRANSFER=>true,
CURLOPT_CUSTOMREQUEST=>"GET",
CURLOPT_AUTOREFERER=>true,
CURLOPT_CONNECTTIMEOUT=>5,
CURLOPT_TIMEOUT=>600,
CURLOPT_FOLLOWLOCATION=>true,
CURLOPT_MAXREDIRS=>20,
CURLOPT_SSL_VERIFYPEER=>false
);
curl_setopt_array($this->curl, $curlOptions);
$result = curl_exec($this->curl);
$status = curl_getinfo($this->curl);
$this->log->ToLog('HTTP error on downloading ' .$url.' ; error = ' . curl_errno($this->curl) . " => ". curl_error($this->curl) . ' ; status = '. json_encode($status) , 'info');
In log I can see
HTTP error on downloading
https://cdn-a.verkkokauppa.com/576/images/83/2_175586-1250x758.jpeg
; error = 0 => ; status = {"url":"https://cdn-a.verkkokauppa.com/576/images/83/2_175586-1250x758.jpeg","content_type":null,"http_code":0,"header_size":0,"request_size":0,"filetime":0,"ssl_verify_result":0,"redirect_count":0,"total_time":0,"namelookup_time":0,"connect_time":0,"pretransfer_time":0,"size_upload":0,"size_download":0,"speed_download":0,"speed_upload":0,"download_content_length":-1,"upload_content_length":-1,"starttransfer_time":0,"redirect_time":0,"redirect_url":"","primary_ip":"","certinfo":[],"primary_port":0,"local_ip":"","local_port":0}
But file_get_contents()
works fine in this case. What happened? How can I fix it?