private function Client::prepareDefaults in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/guzzlehttp/guzzle/src/Client.php \GuzzleHttp\Client::prepareDefaults()
Merges default options into the array.
Parameters
array $options Options to modify by reference:
Return value
array
2 calls to Client::prepareDefaults()
- Client::requestAsync in vendor/
guzzlehttp/ guzzle/ src/ Client.php - Create and send an asynchronous HTTP request.
- Client::sendAsync in vendor/
guzzlehttp/ guzzle/ src/ Client.php - Asynchronously send an HTTP request.
File
- vendor/
guzzlehttp/ guzzle/ src/ Client.php, line 204
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 prepareDefaults($options) {
$defaults = $this->config;
if (!empty($defaults['headers'])) {
// Default headers are only added if they are not present.
$defaults['_conditional'] = $defaults['headers'];
unset($defaults['headers']);
}
// Special handling for headers is required as they are added as
// conditional headers and as headers passed to a request ctor.
if (array_key_exists('headers', $options)) {
// Allows default headers to be unset.
if ($options['headers'] === null) {
$defaults['_conditional'] = null;
unset($options['headers']);
}
elseif (!is_array($options['headers'])) {
throw new \InvalidArgumentException('headers must be an array');
}
}
// Shallow merge defaults underneath options.
$result = $options + $defaults;
// Remove null values.
foreach ($result as $k => $v) {
if ($v === null) {
unset($result[$k]);
}
}
return $result;
}