Skip to content

Commit

Permalink
Fixes #87 and ensures that user agents are only added once per unique…
Browse files Browse the repository at this point in the history
… string.
  • Loading branch information
typhonius committed Oct 6, 2020
1 parent 78b0106 commit e2e522d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/Connector/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class Client implements ClientInterface
*/
protected $options = [];

/**
* @var array User agent strings to be concatenated and added to each request.
*/
protected $userAgent = [];

/**
* Client constructor.
*
Expand Down Expand Up @@ -203,4 +208,20 @@ public function addOption($name, $value): void
{
$this->options = array_merge_recursive($this->options, [$name => $value]);
}

/**
* @inheritdoc
*/
public function setUserAgent($name): void
{
$this->userAgent[$name] = $name;
}

/**
* @inheritdoc
*/
public function getUserAgent(): array
{
return $this->userAgent;
}
}
1 change: 0 additions & 1 deletion tests/Endpoints/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public function testModifyOptions()
$client->addOption('headers', ['User-Agent' => 'AcquiaCli/4.20']);
$client->addOption('headers', ['User-Agent' => 'ZCli/1.1.1']);
$client->addOption('headers', ['User-Agent' => 'AaahCli/0.1']);

$client->addQuery('filter', 'name=@*2014*');
$client->addQuery('filter', 'type=@*true*');
$client->addQuery('limit', '1');
Expand Down

0 comments on commit e2e522d

Please sign in to comment.