Skip to content

Commit c297381

Browse files
committed
timeout
1 parent 4619d6c commit c297381

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/HttpRequest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
class HttpRequest
1313
{
1414
private $_ch;
15-
private $_timeout = 10;
1615
private $_url;
1716
private $_data;
1817

@@ -21,12 +20,17 @@ public function __construct ($url = null) {
2120
if ($url !== null) {
2221
$this->_url = $url;
2322
}
24-
curl_setopt($this->_ch, CURLOPT_TIMEOUT, $this->_timeout);
23+
curl_setopt($this->_ch, CURLOPT_TIMEOUT, 10);
2524
curl_setopt($this->_ch, CURLOPT_RETURNTRANSFER, true);
2625
curl_setopt($this->_ch, CURLOPT_FAILONERROR, true);
2726
curl_setopt($this->_ch, CURLOPT_FOLLOWLOCATION, true);
2827
}
2928

29+
public function setTimeout($timeout) {
30+
curl_setopt($this->_ch, CURLOPT_TIMEOUT, $timeout);
31+
return $this;
32+
}
33+
3034
public function setBasicAuth($username, $password) {
3135
curl_setopt($this->_ch, CURLOPT_USERPWD, $username . ":" . $password);
3236
return $this;

0 commit comments

Comments
 (0)