Skip to content

Commit

Permalink
Merge pull request #1627 from guzzle/revert-1612-minor-clean-up
Browse files Browse the repository at this point in the history
Revert "Minor refactoring"
  • Loading branch information
sagikazarmark committed Oct 23, 2016
2 parents eede767 + 0324c92 commit 310b854
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Client.php
Expand Up @@ -191,10 +191,13 @@ private function configureDefaults(array $config)
if (!isset($this->config['headers'])) {
$this->config['headers'] = ['User-Agent' => default_user_agent()];
} else {
$lowercasedHeaders = array_change_key_case($this->config['headers'], CASE_LOWER);
if (!isset($lowercasedHeaders['user-agent'])) {
$this->config['headers']['User-Agent'] = default_user_agent();
// 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();
}
}

Expand Down Expand Up @@ -231,9 +234,13 @@ private function prepareDefaults($options)
$result = $options + $defaults;

// Remove null values.
return array_filter($result, function ($value) {
return !is_null($value);
});
foreach ($result as $k => $v) {
if ($v === null) {
unset($result[$k]);
}
}

return $result;
}

/**
Expand Down

0 comments on commit 310b854

Please sign in to comment.