Skip to content

Commit d66ae02

Browse files
authored
Curl honor connect_timeout (#81)
1 parent e12ed37 commit d66ae02

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/LaunchDarkly/Impl/Integrations/CurlEventPublisher.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class CurlEventPublisher implements EventPublisher
3030
/** @var string */
3131
private $_curl = '/usr/bin/env curl';
3232

33+
/** @var int */
34+
private $_connectTimeout;
35+
3336
public function __construct(string $sdkKey, array $options = array())
3437
{
3538
$this->_sdkKey = $sdkKey;
@@ -51,6 +54,8 @@ public function __construct(string $sdkKey, array $options = array())
5154
if (array_key_exists('curl', $options)) {
5255
$this->_curl = $options['curl'];
5356
}
57+
58+
$this->_connectTimeout = $options['connect_timeout'];
5459
}
5560

5661
public function publish(string $payload): bool
@@ -64,6 +69,7 @@ private function createArgs(string $payload): string
6469
{
6570
$scheme = $this->_ssl ? "https://" : "http://";
6671
$args = " -X POST";
72+
$args.= " --connect-timeout " . $this->_connectTimeout;
6773
$args.= " -H 'Content-Type: application/json'";
6874
$args.= " -H " . escapeshellarg("Authorization: " . $this->_sdkKey);
6975
$args.= " -H 'User-Agent: PHPClient/" . LDClient::VERSION . "'";

0 commit comments

Comments
 (0)