Adding timeout options to curl

This commit is contained in:
2015-02-28 13:59:45 -07:00
parent 3c0b99efc9
commit a439f98622
3 changed files with 23 additions and 1 deletions
+5
View File
@@ -44,6 +44,7 @@ class BaseHTTP
protected $user;
protected $pass;
protected $base;
protected $timeout;
protected $timePrecision = 's';
protected $children = array();
@@ -60,6 +61,7 @@ class BaseHTTP
$this->pass = $c->pass;
$this->port = $c->port;
$this->host = $c->host;
$this->timeout = $c->timeout;
$this->timePrecision = $c->timePrecision;
$c->children[] = $this;
}
@@ -71,6 +73,9 @@ class BaseHTTP
$url .= "?" . http_build_query($args);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if($this->timeout !== null){
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
}
return $ch;
}
+3 -1
View File
@@ -43,13 +43,15 @@ class Client extends BaseHTTP
protected $port;
protected $user;
protected $pass;
protected $timeout;
public function __construct($host = "localhost", $port = 8086, $u = 'root', $p = 'root')
public function __construct($host = "localhost", $port = 8086, $u = 'root', $p = 'root', $timeout = null)
{
$this->host = $host;
$this->port = $port;
$this->user = $u;
$this->pass = $p;
$this->timeout = $timeout;
}
public function deleteDatabase($name)