Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit e735afd

Browse files
author
Jens Schulze
committed
fix(Guzzle5Adapter): fix applying client options to guzzle5 http client
1 parent cf04c39 commit e735afd

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

src/Core/Client/Adapter/Guzzle5Adapter.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Guzzle5Adapter implements AdapterOptionInterface, CorrelationIdAware, Toke
3535
*/
3636
protected $logger;
3737

38-
private $concurrency;
38+
private $concurrency = self::DEFAULT_CONCURRENCY;
3939

4040
/**
4141
* @param array $options
@@ -47,24 +47,22 @@ public function __construct(array $options = [])
4747
unset($options['base_uri']);
4848
}
4949
if (isset($options['concurrency'])) {
50-
$options['pool_size'] = $options['concurrency'];
50+
$this->concurrency = $options['concurrency'];
5151
unset($options['concurrency']);
5252
}
5353
if (isset($options['headers'])) {
5454
$options['defaults']['headers'] = $options['headers'];
5555
unset($options['headers']);
5656
}
57-
$options = array_merge(
57+
$options['defaults'] = array_merge(
5858
[
5959
'allow_redirects' => false,
6060
'verify' => true,
6161
'timeout' => 60,
62-
'connect_timeout' => 10,
63-
'pool_size' => self::DEFAULT_CONCURRENCY
62+
'connect_timeout' => 10
6463
],
65-
$options
64+
isset($options['defaults']) ? $options['defaults'] : []
6665
);
67-
$this->concurrency = $options['pool_size'];
6866

6967
$this->client = new Client($options);
7068
}

tests/unit/Client/OAuth/ManagerTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,18 @@ public function testOAuthUrl()
288288

289289
public function testSetClientOptions()
290290
{
291+
if (version_compare(HttpClient::VERSION, '6.0.0', '>=')) {
292+
$clientOptions = ['verify' => false];
293+
} else {
294+
$clientOptions = ['defaults' => ['verify' => false]];
295+
}
291296
$config = Config::of()->setClientId('')->setClientSecret('')->setProject('');
292297
$manager = new Manager($config);
293298

294299
$this->assertInstanceOf(ConfigAware::class, $manager->getHttpClient());
295300
$this->assertTrue($manager->getHttpClient()->getConfig('verify'));
296301

297-
$config = Config::of()->setClientId('')->setClientSecret('')->setProject('')->setOAuthClientOptions(['verify' => false]);
302+
$config = Config::of()->setClientId('')->setClientSecret('')->setProject('')->setOAuthClientOptions($clientOptions);
298303
$manager = new Manager($config);
299304

300305
$this->assertInstanceOf(ConfigAware::class, $manager->getHttpClient());

tests/unit/ClientTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,14 +810,19 @@ public function testHtmlBody()
810810

811811
public function testSetClientOptions()
812812
{
813+
if (version_compare(HttpClient::VERSION, '6.0.0', '>=')) {
814+
$clientOptions = ['verify' => false];
815+
} else {
816+
$clientOptions = ['defaults' => ['verify' => false]];
817+
}
813818
$client = Client::ofConfig(
814819
Config::of()->setClientId('')->setClientSecret('')->setProject('')
815820
);
816821
$this->assertInstanceOf(ConfigAware::class, $client->getHttpClient());
817822
$this->assertTrue($client->getHttpClient()->getConfig('verify'));
818823

819824
$client = Client::ofConfig(
820-
Config::of()->setClientId('')->setClientSecret('')->setProject('')->setClientOptions(['verify' => false])
825+
Config::of()->setClientId('')->setClientSecret('')->setProject('')->setClientOptions($clientOptions)
821826
);
822827
$this->assertInstanceOf(ConfigAware::class, $client->getHttpClient());
823828
$this->assertFalse($client->getHttpClient()->getConfig('verify'));

0 commit comments

Comments
 (0)