Throw InvalidArgumentException when an incorrect headers array is provided#2942
Merged
GrahamCampbell merged 2 commits intoguzzle:masterfrom Oct 17, 2021
Merged
Conversation
… provided As discussed in PR guzzle#2916 after it was merged an `InvalidArgumentException` is more fitting, as passing an invalid `headers` array is a clear programming error that needs to be fixed and not caught. This is consistent with the validation of the other options, e.g. when using `multipart` and `form_params` at the same time. see guzzle#2916 see a2b8dd1
TimWolla
commented
Oct 13, 2021
| @@ -346,7 +345,7 @@ private function applyOptions(RequestInterface $request, array &$options): Reque | |||
|
|
|||
| if (isset($options['headers'])) { | |||
| if (array_keys($options['headers']) === range(0, count($options['headers']) - 1)) { | |||
Contributor
Author
There was a problem hiding this comment.
FWIW: This could be array_is_list() in PHP 8.1 / by importing Symfony's symfony/polyfill-php81.
b4376c8 to
62ca561
Compare
GrahamCampbell
approved these changes
Oct 17, 2021
Member
|
Thank you. Your keen eye is much appreciated. 🍻 |
Contributor
Author
|
My pleasure. Happy to give back to libraries we are relying on, even if it's just the little things. |
Member
|
6.4.0 has now been released, including this fix. :) |
Contributor
Author
|
7.4.0 you mean 😛 I've already seen it, thanks. |
Member
|
yep 😆 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As discussed in PR #2916 after it was merged an
InvalidArgumentExceptionismore fitting, as passing an invalid
headersarray is a clear programmingerror that needs to be fixed and not caught.
This is consistent with the validation of the other options, e.g. when using
multipartandform_paramsat the same time.see #2916
see a2b8dd1
/cc @GrahamCampbell; thanks