Commit 0178d323 authored by Yevgen Kovalienia's avatar Yevgen Kovalienia

CURL and PECL_HTTP adapters set connection timeout and dns cache timeout...

CURL and PECL_HTTP adapters set connection timeout and dns cache timeout (which is equal to "timeout" option value)
parent 27d51fe4
......@@ -149,6 +149,7 @@ class Curl extends Configurable implements AdapterInterface
curl_setopt($handler, CURLOPT_FOLLOWLOCATION, true);
}
curl_setopt($handler, CURLOPT_TIMEOUT, $options['timeout']);
curl_setopt($handler, CURLOPT_CONNECTTIMEOUT, $options['timeout']);
if ($proxy = $this->getOption('proxy')) {
curl_setopt($handler, CURLOPT_PROXY, $proxy);
......
......@@ -132,6 +132,9 @@ class PeclHttp extends Configurable implements AdapterInterface
* {@link http://us.php.net/manual/en/http.constants.php
* HTTP Predefined Constant}
*
* {@link http://us.php.net/manual/en/http.request.options.php
* HttpRequest options}
*
* @throws InvalidArgumentException
* @param Request $request
* @param Endpoint $endpoint
......@@ -190,7 +193,13 @@ class PeclHttp extends Configurable implements AdapterInterface
}
$httpRequest->setMethod($method);
$httpRequest->setOptions(array('timeout' => $endpoint->getTimeout()));
$httpRequest->setOptions(
array(
'timeout' => $endpoint->getTimeout(),
'connecttimeout' => $endpoint->getTimeout(),
'dns_cache_timeout' => $endpoint->getTimeout(),
)
);
$httpRequest->setHeaders($headers);
return $httpRequest;
......
......@@ -129,6 +129,8 @@ class PeclHttpTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(
array(
'timeout' => 10,
'connecttimeout' => 10,
'dns_cache_timeout' => 10,
'headers' => array(
'Content-Type' => 'application/json',
'User-Agent' => 'Foo',
......
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