mirror of
https://github.com/guzzle/guzzle.git
synced 2025-05-02 04:38:14 +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);
|
$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
|
// 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);
|
$curlOption = str_replace('curl.', '', $key);
|
||||||
if (defined($curlOption)) {
|
if (defined($curlOption)) {
|
||||||
$curlValue = defined($value) ? constant($value) : $value;
|
$curlValue = defined($value) ? constant($value) : $value;
|
||||||
$request->getCurlOptions()->set(constant($curlOption), $curlValue);
|
$request->getCurlOptions()->set(constant($curlOption), $curlValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Add any cache options from the config to the request
|
||||||
// Add the cache key filter to requests if one is set on the client
|
// Add any curl options that might in the config to the request
|
||||||
if ($this->getConfig('cache.key_filter')) {
|
if (strpos($key, 'cache.') === 0) {
|
||||||
$request->getParams()->set('cache.key_filter', $this->getConfig('cache.key_filter'));
|
$request->getParams()->set($key, $value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach client observers to the request
|
// Attach client observers to the request
|
||||||
|
Loading…
x
Reference in New Issue
Block a user