mirror of
https://github.com/guzzle/guzzle.git
synced 2025-05-01 12:23:56 +02:00
[Http] Passing any config settings in a client that start with "cache." to the params of a each request created by the client
This commit is contained in:
parent
8aee7da90c
commit
de4fb29c9b
@ -165,18 +165,20 @@ class Client extends AbstractHasDispatcher implements ClientInterface
|
||||
$request->setHeader('User-Agent', $this->userAgent);
|
||||
}
|
||||
|
||||
foreach ($this->getConfig()->getAll() as $key => $value) {
|
||||
// Add any curl options that might in the config to the request
|
||||
foreach ($this->getConfig()->getAll('/^curl\..+/', Collection::MATCH_REGEX) as $key => $value) {
|
||||
if (strpos($key, 'curl.') === 0) {
|
||||
$curlOption = str_replace('curl.', '', $key);
|
||||
if (defined($curlOption)) {
|
||||
$curlValue = defined($value) ? constant($value) : $value;
|
||||
$request->getCurlOptions()->set(constant($curlOption), $curlValue);
|
||||
}
|
||||
}
|
||||
|
||||
// Add the cache key filter to requests if one is set on the client
|
||||
if ($this->getConfig('cache.key_filter')) {
|
||||
$request->getParams()->set('cache.key_filter', $this->getConfig('cache.key_filter'));
|
||||
// Add any cache options from the config to the request
|
||||
// Add any curl options that might in the config to the request
|
||||
if (strpos($key, 'cache.') === 0) {
|
||||
$request->getParams()->set($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// Attach client observers to the request
|
||||
|
Loading…
x
Reference in New Issue
Block a user