diff --git a/api/RestfulService.php b/api/RestfulService.php index 76508a132..5f8d7ae29 100644 --- a/api/RestfulService.php +++ b/api/RestfulService.php @@ -1,17 +1,21 @@ Version(); $curlOptions = $curlOptions + (array)$this->config()->default_curl_options; @@ -221,7 +224,7 @@ class RestfulService extends ViewableData { curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, $useragent); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->getConnectTimeout()); if(!ini_get('open_basedir')) curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); @@ -553,6 +556,31 @@ class RestfulService extends ViewableData { return $output; } + + /** + * Set the connection timeout for the curl request in seconds. + * + * @see http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCONNECTTIMEOUT + * + * @param int + * + * @return RestfulService + */ + public function setConnectTimeout($timeout) { + $this->connectTimeout = $timeout; + + return $this; + } + + /** + * Return the connection timeout value. + * + * @return int + */ + public function getConnectTimeout() { + return $this->connectTimeout; + } + } /**