Skip to content

Commit

Permalink
Merge pull request #23 from Nexylan/timeout-option
Browse files Browse the repository at this point in the history
Add the possibility to change the request timeout via an option
  • Loading branch information
zsiddique committed Apr 28, 2015
2 parents f928cc4 + a0e5d04 commit 5936c0a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/HipChat/HipChat.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class HipChat {
private $auth_token;
private $verify_ssl = true;
private $proxy;
private $request_timeout = 15;

/**
* Creates a new API interaction object.
Expand Down Expand Up @@ -364,7 +365,7 @@ public function curl_request($url, $post_data = null) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->request_timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verify_ssl);
if (isset($this->proxy)) {
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
Expand Down Expand Up @@ -477,6 +478,18 @@ public function set_proxy($proxy) {
$this->proxy = $proxy;
}

/**
* Change CURL request timeout.
* You can change this value if you want to change request timeout toleration.
*
* @param int $timeout
*
* @return int
*/
public function set_request_timeout($timeout = 15) {
$this->request_timeout = (int)$timeout;
return $this->request_timeout;
}
}


Expand Down

0 comments on commit 5936c0a

Please sign in to comment.