private function Client::configureDefaults in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/guzzlehttp/guzzle/src/Client.php \GuzzleHttp\Client::configureDefaults()
Configures the default options for a client.
Parameters
array $config:
1 call to Client::configureDefaults()
- Client::__construct in vendor/
guzzlehttp/ guzzle/ src/ Client.php - Clients accept an array of constructor parameters.
File
- vendor/
guzzlehttp/ guzzle/ src/ Client.php, line 153
Class
- Client
- @method ResponseInterface get($uri, array $options = []) @method ResponseInterface head($uri, array $options = []) @method ResponseInterface put($uri, array $options = []) @method ResponseInterface post($uri, array $options = []) @method…
Namespace
GuzzleHttpCode
private function configureDefaults(array $config) {
$defaults = [
'allow_redirects' => RedirectMiddleware::$defaultSettings,
'http_errors' => true,
'decode_content' => true,
'verify' => true,
'cookies' => false,
];
// Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set
if ($proxy = getenv('HTTP_PROXY')) {
$defaults['proxy']['http'] = $proxy;
}
if ($proxy = getenv('HTTPS_PROXY')) {
$defaults['proxy']['https'] = $proxy;
}
if ($noProxy = getenv('NO_PROXY')) {
$cleanedNoProxy = str_replace(' ', '', $noProxy);
$defaults['proxy']['no'] = explode(',', $cleanedNoProxy);
}
$this->config = $config + $defaults;
if (!empty($config['cookies']) && $config['cookies'] === true) {
$this->config['cookies'] = new CookieJar();
}
// Add the default user-agent header.
if (!isset($this->config['headers'])) {
$this->config['headers'] = [
'User-Agent' => default_user_agent(),
];
}
else {
// Add the User-Agent header if one was not already set.
foreach (array_keys($this->config['headers']) as $name) {
if (strtolower($name) === 'user-agent') {
return;
}
}
$this->config['headers']['User-Agent'] = default_user_agent();
}
}