Skip to content

Commit

Permalink
✨ Adicionando parametro timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoapaes committed Oct 29, 2024
1 parent 2952d76 commit 5aa6f6e
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 5aa6f6e

Please sign in to comment.