Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature symfony#52946 [HttpClient] Add HttpOptions->addHeader as a sh…
…ortcut to add an header in an existing options object (Dean151) This PR was squashed before being merged into the 7.1 branch. Discussion ---------- [HttpClient] Add HttpOptions->addHeader as a shortcut to add an header in an existing options object | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | | License | MIT Currently, the HttpOptions object only provide a ->setHeaders option that override every existing headers. When we are provided an HttpOptions to customize a request, adding a request header requires to get the whole headers array, update it, and then set it back in the HttpOptions object. This DX improvement brings an addHeader option, allowing to add an header to the set without having to manage the existing ones. When the header option is not yet provided, the ??= operator makes sure the headers is initialized with an empty array (PHP >= 7.4) When a header is already provided, it is overwritten. Commits ------- 266e50f [HttpClient] Add HttpOptions->addHeader as a shortcut to add an header in an existing options object
- Loading branch information