Skip to content

Commit

Permalink
Merge pull request #29 from likesistemas/add-timeout
Browse files Browse the repository at this point in the history
✨ Adicionando parametro timeout
  • Loading branch information
robmachado authored Oct 29, 2024
2 parents 2952d76 + 5aa6f6e commit 0c29212
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,20 @@ class Rest implements RestInterface
*/
protected $proxy = [];

protected $timeout;

/**
* Constructor
*
* @param array $proxy Parameter for proxy ['IP','PORT','USER','PASS']
*/
public function __construct($proxy = [])
public function __construct($proxy = [], $timeout = 10)
{
if (!empty($proxy)) {
$this->proxy = $proxy;
}

$this->timeout = $timeout;
}

/**
Expand All @@ -64,7 +68,7 @@ public function pull($uri)
$this->setProxy($oCurl, $this->proxy);
}
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($oCurl, CURLOPT_TIMEOUT, 10);
curl_setopt($oCurl, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($oCurl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, 0);
Expand Down

0 comments on commit 0c29212

Please sign in to comment.