Commit 5dff6bec authored by Keven's avatar Keven
Browse files

Added a timeout accessor on the Client

parent 59b04e04
......@@ -104,6 +104,12 @@ class CurlClient implements LoggerAwareInterface
*/
private $headers = array();
/**
*
* @var int Request timeout in seconds
*/
private $timeout;
/**
*
*/
......@@ -117,10 +123,10 @@ class CurlClient implements LoggerAwareInterface
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_MAXREDIRS => 5,
CURLOPT_TIMEOUT_MS => 30000, // 30s
CURLOPT_CONNECTTIMEOUT_MS => 30000, // 30s
)
);
$this->setTimeout(30);
}
/**
......@@ -143,6 +149,26 @@ class CurlClient implements LoggerAwareInterface
));
}
/**
*
* @param int $seconds
*/
public function setTimeout($seconds)
{
curl_setopt($this->handle, CURLOPT_TIMEOUT_MS, 1000 * $seconds);
curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT_MS, 1000 * $seconds);
$this->timeout = $seconds;
}
/**
*
* @return int
*/
public function getTimeout()
{
return $this->timeout;
}
/**
*
* @param string $username
......@@ -249,7 +275,7 @@ class CurlClient implements LoggerAwareInterface
$headers = substr($response, 0, $header_size);
$this->log('Curl response: '.substr($response, $header_size), LogLevel::DEBUG);
echo ' < '.substr($response, $header_size)."\n";
return new Response(
$statusCode,
// Temporary bypassed:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment