mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #3108 from dhensby/master
Revert "FIX: allow CURLOPT_CONNECTTIMEOUT to be configured."
This commit is contained in:
commit
d01083cfce
@ -1,21 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* RestfulService class allows you to consume various RESTful APIs.
|
* RestfulService class allows you to consume various RESTful APIs.
|
||||||
*
|
|
||||||
* Through this you could connect and aggregate data of various web services.
|
* Through this you could connect and aggregate data of various web services.
|
||||||
*
|
* For more info visit wiki documentation - http://doc.silverstripe.org/doku.php?id=restfulservice
|
||||||
* @see http://doc.silverstripe.org/framework/en/reference/restfulservice
|
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage integration
|
* @subpackage integration
|
||||||
*/
|
*/
|
||||||
class RestfulService extends ViewableData {
|
class RestfulService extends ViewableData {
|
||||||
|
|
||||||
protected $baseURL;
|
protected $baseURL;
|
||||||
protected $queryString;
|
protected $queryString;
|
||||||
protected $errorTag;
|
protected $errorTag;
|
||||||
protected $checkErrors;
|
protected $checkErrors;
|
||||||
protected $connectTimeout = 5;
|
|
||||||
protected $cache_expire;
|
protected $cache_expire;
|
||||||
protected $authUsername, $authPassword;
|
protected $authUsername, $authPassword;
|
||||||
protected $customHeaders = array();
|
protected $customHeaders = array();
|
||||||
@ -217,6 +213,7 @@ class RestfulService extends ViewableData {
|
|||||||
*/
|
*/
|
||||||
public function curlRequest($url, $method, $data = null, $headers = null, $curlOptions = array()) {
|
public function curlRequest($url, $method, $data = null, $headers = null, $curlOptions = array()) {
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
$timeout = 5;
|
||||||
$sapphireInfo = new SapphireInfo();
|
$sapphireInfo = new SapphireInfo();
|
||||||
$useragent = 'SilverStripe/' . $sapphireInfo->Version();
|
$useragent = 'SilverStripe/' . $sapphireInfo->Version();
|
||||||
$curlOptions = $curlOptions + (array)$this->config()->default_curl_options;
|
$curlOptions = $curlOptions + (array)$this->config()->default_curl_options;
|
||||||
@ -224,7 +221,7 @@ class RestfulService extends ViewableData {
|
|||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
|
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
|
||||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->getConnectTimeout());
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
|
||||||
if(!ini_get('open_basedir')) curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
|
if(!ini_get('open_basedir')) curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
|
||||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
||||||
|
|
||||||
@ -556,31 +553,6 @@ class RestfulService extends ViewableData {
|
|||||||
|
|
||||||
return $output;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user