Skip to content
Snippets Groups Projects
Verified Commit 5ebaaa8e authored by Pavel Břoušek's avatar Pavel Břoušek
Browse files

feat: timeout and connectTimeout options

parent 0ad159d6
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,16 @@ class PrivacyIDEA ...@@ -42,6 +42,16 @@ class PrivacyIDEA
*/ */
public $sslVerifyPeer = true; public $sslVerifyPeer = true;
/**
* @var int cURL connect timeout in seconds
*/
public $connectTimeout = 0;
/**
* @var int cURL timeout in seconds
*/
public $timeout;
/** /**
* @var string Account name for a service account to the privacyIDEA server. This is required to use the /validate/triggerchallenge endpoint. * @var string Account name for a service account to the privacyIDEA server. This is required to use the /validate/triggerchallenge endpoint.
*/ */
...@@ -391,6 +401,10 @@ class PrivacyIDEA ...@@ -391,6 +401,10 @@ class PrivacyIDEA
$completeUrl = $this->serverURL . $endpoint; $completeUrl = $this->serverURL . $endpoint;
$curlInstance = curl_init(); $curlInstance = curl_init();
curl_setopt($curlInstance, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout);
if (null !== $this->timeout) {
curl_setopt($curlInstance, CURLOPT_TIMEOUT, $this->timeout);
}
curl_setopt($curlInstance, CURLOPT_URL, $completeUrl); curl_setopt($curlInstance, CURLOPT_URL, $completeUrl);
curl_setopt($curlInstance, CURLOPT_HEADER, true); curl_setopt($curlInstance, CURLOPT_HEADER, true);
if ($headers) { if ($headers) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment