-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[HttpClient] Fix ScopingHttpClient to always pass base_uri as string instead of parsed array
#62699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HttpClient] Fix ScopingHttpClient to always pass base_uri as string instead of parsed array
#62699
Conversation
b2e344c to
d2eec31
Compare
| if (\is_array($options['base_uri'] ?? null)) { | ||
| $options['base_uri'] = $this->unparseUrl($options['base_uri']); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m converting the URL back to a string because we currently allow passing base_uri as either a string or an array.
Ideally ( i think ), we should stop accepting arrays for base_uri, but removing that support in a patch or minor version would be a breaking change.
d2eec31 to
04ba787
Compare
|
status: needs work |
04ba787 to
165b263
Compare
|
status: needs review |
…ring` instead of parsed `array`
165b263 to
9f80dd4
Compare
nicolas-grekas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went a little bit further and I'm now unsetting the option when resolving URLs.
The code was able to cope with a parsed array instead of a string, but this conflicted with RetryableHttpClient's expectation and was also not documented as a valid type for the option.
|
Thank you @santysisi. |
|
Thanks to both of you for fixing this 🙏 |
Problem
ScopingHttpClientparsed thebase_uriinto anarray(scheme, path, query, etc.).RetryableHttpClient, it caused errors.HttpClientInterfacein Symfony Contracts,base_urimust be a stringSolution
ScopingHttpClientso it always forwardsbase_urias astring, not as a parsed array.RetryableHttpClient, since sending anarraywas not compliant with theHttpClientInterfacecomment.Additional Notes
Originally, the idea was to apply this fix only when the decorated client was
RetryableHttpClientand later add full support for parsedbase_uriforRetryableHttpClientin version 8.1.However, after reviewing the
HttpClientInterface, it became clear that sending a parsedarrayforbase_uriwas incorrect.Therefore, the behavior is now corrected universally.