mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-10-09 16:11:19 +02:00
[WEB-19] Handle missing ext-curl by checking CURLOPT_TIMEOUT constant
This commit is contained in:
1 parent
23002b7149
commit
aa75bb0e23
2 files changed
+12
-1
No files matched your search
@@ -120,8 +120,11 @@ class JsonRpcClientManager
|
||||
* `JsonRPC\HttpClient` doesn't set `CURLOPT_TIMEOUT` (limit of the whole request, including reading
|
||||
* the response) at all by default, so without this a slow/unresponsive LimeSurvey instance could hang
|
||||
* the request for a very long time.
|
||||
*
|
||||
* `CURLOPT_TIMEOUT` is only defined when ext-curl is loaded, so the option is skipped in stream-based
|
||||
* environments to avoid a fatal error on the undefined constant.
|
||||
*/
|
||||
if (null !== $this->connectionConfiguration->getRequestTimeout()) {
|
||||
if (null !== $this->connectionConfiguration->getRequestTimeout() && defined('CURLOPT_TIMEOUT')) {
|
||||
$this
|
||||
->rpcClient
|
||||
->getHttpClient()
|
||||
|
||||
@@ -113,6 +113,10 @@ class JsonRpcClientManagerTest extends BaseTestCase
|
||||
|
||||
public function testGetRpcClientWithoutTimeoutsDoesNotTouchHttpClientDefaults()
|
||||
{
|
||||
if (!extension_loaded('curl')) {
|
||||
$this->markTestSkipped('ext-curl is required to assert CURLOPT_TIMEOUT options.');
|
||||
}
|
||||
|
||||
$configuration = new ConnectionConfiguration('http://test.com', 'test', 'test');
|
||||
$httpClient = $this->getHttpClientOfManager(new JsonRpcClientManager($configuration));
|
||||
|
||||
@@ -122,6 +126,10 @@ class JsonRpcClientManagerTest extends BaseTestCase
|
||||
|
||||
public function testGetRpcClientAppliesConnectAndRequestTimeout()
|
||||
{
|
||||
if (!extension_loaded('curl')) {
|
||||
$this->markTestSkipped('ext-curl is required to assert CURLOPT_TIMEOUT options.');
|
||||
}
|
||||
|
||||
$configuration = new ConnectionConfiguration('http://test.com', 'test', 'test', false, true, 2, 7);
|
||||
$httpClient = $this->getHttpClientOfManager(new JsonRpcClientManager($configuration));
|
||||
|
||||
|
||||
Reference in new issue
Block a user