Adding connect timeout as well

This commit is contained in:
Will Bradley 2015-03-20 22:01:49 -07:00
parent a439f98622
commit 830b11c647
2 changed files with 10 additions and 2 deletions

View File

@ -45,6 +45,7 @@ class BaseHTTP
protected $pass;
protected $base;
protected $timeout;
protected $connectTimeout;
protected $timePrecision = 's';
protected $children = array();
@ -62,6 +63,7 @@ class BaseHTTP
$this->port = $c->port;
$this->host = $c->host;
$this->timeout = $c->timeout;
$this->connectTimeout = $c->connectTimeout;
$this->timePrecision = $c->timePrecision;
$c->children[] = $this;
}
@ -73,8 +75,12 @@ class BaseHTTP
$url .= "?" . http_build_query($args);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
var_dump($this->timeout);
if($this->timeout !== null){
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
}
if($this->connectTimeout !== null){
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout);
}
return $ch;
}

View File

@ -44,14 +44,16 @@ class Client extends BaseHTTP
protected $user;
protected $pass;
protected $timeout;
protected $connectTimeout;
public function __construct($host = "localhost", $port = 8086, $u = 'root', $p = 'root', $timeout = null)
public function __construct($host = "localhost", $port = 8086, $u = 'root', $p = 'root', $timeout = null, $connectTimeout = null)
{
$this->host = $host;
$this->port = $port;
$this->user = $u;
$this->pass = $p;
$this->timeout = $timeout;
$this->connectTimeout = $connectTimeout;
}
public function deleteDatabase($name)