Skip to content

Commit 1b1b744

Browse files
committed
Make sure we vary on the Authorization header
1 parent 387d21e commit 1b1b744

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"php-http/discovery": "^1.0",
2525
"php-http/client-implementation": "^1.0",
2626
"php-http/client-common": "^1.3",
27-
"php-http/cache-plugin": "^1.3"
27+
"php-http/cache-plugin": "^1.4"
2828
},
2929
"require-dev": {
3030
"phpunit/phpunit": "^4.0 || ^5.5",

lib/Github/HttpClient/Builder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Http\Message\RequestFactory;
1414
use Http\Message\StreamFactory;
1515
use Psr\Cache\CacheItemPoolInterface;
16+
use Http\Client\Common\Plugin\Cache\Generator\VaryGenerator;
1617

1718
/**
1819
* A builder that builds the API client.
@@ -181,6 +182,9 @@ public function addHeaderValue($header, $headerValue)
181182
*/
182183
public function addCache(CacheItemPoolInterface $cachePool, array $config = [])
183184
{
185+
if (!isset($config['cache_key_generator'])) {
186+
$config['cache_key_generator'] = new VaryGenerator(['Authorization']);
187+
}
184188
$this->cachePlugin = Plugin\CachePlugin::clientCache($cachePool, $this->streamFactory, $config);
185189
$this->httpClientModified = true;
186190
}

0 commit comments

Comments
 (0)