fixed default header override caused by array union (#1727)

* Fix header merge

We should use array_merge to append and reindex header array, + causes an issue where if we add a header, like for example Authorization, then the first item in merged header will be skipped (Content-Type) as there will already be a header at 0 index of array. + does not replace values which keys already exist in arrays

* Update CHANGELOG.md
This commit is contained in:
Justinas 2018-10-07 16:41:11 +03:00 committed by Anton Medvedev
parent ad8e77579d
commit 075b5b5d0a
2 changed files with 5 additions and 4 deletions

View File

@ -14,6 +14,7 @@
### Fixed
- Fixed Range expansion when hosts.yml is loaded. [#1671]
- Fixed usage (only if present) of deploy_path config setting. [#1677]
- Fixed adding custom headers causes Httpie default header override.
## v6.3.0

View File

@ -59,10 +59,10 @@ class Httpie
{
$http = clone $this;
$http->body = json_encode($data, JSON_PRETTY_PRINT);
$http->headers += [
$http->headers = array_merge($http->headers, [
'Content-Type: application/json',
'Content-Length: ' . strlen($http->body)
];
]);
return $http;
}
@ -70,10 +70,10 @@ class Httpie
{
$http = clone $this;
$http->body = http_build_query($data);
$http->headers += [
$http->headers = array_merge($this->headers, [
'Content-type: application/x-www-form-urlencoded',
'Content-Length: ' . strlen($http->body)
];
]);
return $http;
}