From 021cfda1e2f8c987de548bbae0f6d499ba87afcf Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 3 Jul 2013 07:47:56 -0700 Subject: [PATCH] CRM_Utils_HttpClient - Fix timeout --- CRM/Utils/HttpClient.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CRM/Utils/HttpClient.php b/CRM/Utils/HttpClient.php index 1c3b10ab5d..c3b82b9bcd 100644 --- a/CRM/Utils/HttpClient.php +++ b/CRM/Utils/HttpClient.php @@ -50,9 +50,9 @@ class CRM_Utils_HttpClient { protected static $singleton; /** - * @var int + * @var int|NULL seconds; or NULL to use system default */ - protected $timeout; + protected $connectionTimeout; public static function singleton() { if (!self::$singleton) { @@ -61,8 +61,8 @@ class CRM_Utils_HttpClient { return self::$singleton; } - public function __construct($timeout = 10) { - $this->timeout = $timeout; + public function __construct($connectionTimeout = NULL) { + $this->connectionTimeout = $connectionTimeout; } /** @@ -190,6 +190,9 @@ class CRM_Utils_HttpClient { curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); + if ($this->connectionTimeout !== NULL) { + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectionTimeout); + } if (preg_match('/^https:/', $remoteFile) && $caConfig->isEnableSSL()) { curl_setopt_array($ch, $caConfig->toCurlOptions()); } -- 2.25.1