diff --git a/src/Jira/Api/Client/CurlClient.php b/src/Jira/Api/Client/CurlClient.php index 9e3acb8..fc18ebd 100644 --- a/src/Jira/Api/Client/CurlClient.php +++ b/src/Jira/Api/Client/CurlClient.php @@ -33,6 +33,12 @@ class CurlClient implements ClientInterface { + /** + * Default timeout for CURL requests + * + * @var int seconds + */ + protected $timeout = 10; /** * create a traditional php client @@ -93,6 +99,9 @@ public function sendRequest( curl_setopt($curl, CURLOPT_USERPWD, sprintf('%s:%s', $credential->getId(), $credential->getPassword())); } + if (is_numeric($this->timeout)) { + curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout); + } curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_VERBOSE, $debug); diff --git a/tests/Jira/Api/Client/CurlClientTest.php b/tests/Jira/Api/Client/CurlClientTest.php index 84f7bf3..eaf1aeb 100644 --- a/tests/Jira/Api/Client/CurlClientTest.php +++ b/tests/Jira/Api/Client/CurlClientTest.php @@ -19,4 +19,8 @@ protected function createClient() return new CurlClient(); } + protected function testTimeout() + { + return new CurlClient(); + } }