From 5aa6f6e7bcb2f38ffaa300dad8477937e77cf7ee Mon Sep 17 00:00:00 2001 From: Ricardo Paes Date: Tue, 29 Oct 2024 11:32:03 -0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Adicionando=20parametro=20timeout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Rest.php b/src/Rest.php index 82d7251..5819721 100755 --- a/src/Rest.php +++ b/src/Rest.php @@ -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; } /** @@ -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);