php-mod/curl

init() should set CURLOPT_CONNECTTIMEOUT

islishude opened this issue · 0 comments

Curl.php doesn't set CURLOPT_CONNECTTIMEOUT

private function init()
 {
   $this->curl = curl_init();
   $this->setUserAgent(self::USER_AGENT);
   $this->setOpt(CURLINFO_HEADER_OUT, true);
   $this->setOpt(CURLOPT_HEADER, true);
   $this->setOpt(CURLOPT_RETURNTRANSFER, true);
   return $this;
 }

My code like follow

use Curl\Curl;

$curl = new Curl();
for($i=1;i<200;$i++){
    $res = json_decode($curl->get('api url' . $i)->response);
    $data = $res->data;
}

So $data isn't sure that get data from $res,because the $res may be a null, and $data = $res ->data may repote errors.