Skip to content

[HttpClient] Fix option "resolve" with IPv6 addresses #58915

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

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

@carsonbot carsonbot added this to the 5.4 milestone Nov 18, 2024
@nicolas-grekas nicolas-grekas force-pushed the hc-ipv6-resolve branch 2 times, most recently from 7d41709 to 5c757be Compare November 19, 2024 09:38
@@ -79,6 +79,9 @@ public function request(string $method, string $url, array $options = []): Respo
if (str_starts_with($options['bindto'], 'host!')) {
$options['bindto'] = substr($options['bindto'], 5);
}
if ((\PHP_VERSION_ID < 80223 || 80300 <= \PHP_VERSION_ID && 80311 < \PHP_VERSION_ID) && '\\' === \DIRECTORY_SEPARATOR && '[' === $options['bindto'][0]) {
$options['bindto'] = preg_replace('{^\[[^\]]++\]}', '[$0]', $options['bindto']);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the failure on Windows. I verified that on Windows, before PHP 8.2.23, bindto needs double brackets for binding to IPv6 addresses ([[::1]]:0).

I looked at the changelog of PHP 8.2.23 and the only PR that looks related is
php/php-src#15068

I also compiled PHP 8.2.22 on my Ubuntu and the issue doesn't show up, while it does on Windows with the same version.

@nicolas-grekas nicolas-grekas merged commit aea227a into symfony:5.4 Nov 19, 2024
9 of 11 checks passed
@nicolas-grekas nicolas-grekas deleted the hc-ipv6-resolve branch November 19, 2024 10:04
nicolas-grekas added a commit that referenced this pull request Nov 20, 2024
…nt 5 (xabbuh)

This PR was merged into the 7.2 branch.

Discussion
----------

[HttpClient] resolve IPv6 addresses with amphp/http-client 5

| Q             | A
| ------------- | ---
| Branch?       | 7.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

following the changes from #58915

Commits
-------

3a732af resolve IPv6 addresses with amphp/http-client 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants