Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e3f2350

Browse filesBrowse files
[HttpClient] Fix option "resolve" with IPv6 addresses
1 parent af1a3f2 commit e3f2350
Copy full SHA for e3f2350

File tree

Expand file treeCollapse file tree

2 files changed

+25
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+25
-3
lines changed

‎Test/HttpClientTestCase.php

Copy file name to clipboardExpand all lines: Test/HttpClientTestCase.php
+17-2Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,18 @@ public function testIdnResolve()
735735
$this->assertSame(200, $response->getStatusCode());
736736
}
737737

738+
public function testIPv6Resolve()
739+
{
740+
TestHttpServer::start(-8087, '[::1]');
741+
742+
$client = $this->getHttpClient(__FUNCTION__);
743+
$response = $client->request('GET', 'http://symfony.com:8087/', [
744+
'resolve' => ['symfony.com' => '::1'],
745+
]);
746+
747+
$this->assertSame(200, $response->getStatusCode());
748+
}
749+
738750
public function testNotATimeout()
739751
{
740752
$client = $this->getHttpClient(__FUNCTION__);
@@ -1168,7 +1180,7 @@ public function testBindToPort()
11681180

11691181
public function testBindToPortV6()
11701182
{
1171-
TestHttpServer::start(8087, '[::1]');
1183+
TestHttpServer::start(-8087);
11721184

11731185
$client = $this->getHttpClient(__FUNCTION__);
11741186
$response = $client->request('GET', 'http://[::1]:8087', ['bindto' => '[::1]:9876']);
@@ -1177,6 +1189,9 @@ public function testBindToPortV6()
11771189
$vars = $response->toArray();
11781190

11791191
self::assertSame('::1', $vars['REMOTE_ADDR']);
1180-
self::assertSame('9876', $vars['REMOTE_PORT']);
1192+
1193+
if ('\\' !== \DIRECTORY_SEPARATOR) {
1194+
self::assertSame('9876', $vars['REMOTE_PORT']);
1195+
}
11811196
}
11821197
}

‎Test/TestHttpServer.php

Copy file name to clipboardExpand all lines: Test/TestHttpServer.php
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,15 @@ class TestHttpServer
2121
/**
2222
* @return Process
2323
*/
24-
public static function start(int $port = 8057, $ip = '127.0.0.1')
24+
public static function start(int $port = 8057)
2525
{
26+
if (0 > $port) {
27+
$port = -$port;
28+
$ip = '[::1]';
29+
} else {
30+
$ip = '127.0.0.1';
31+
}
32+
2633
if (isset(self::$process[$port])) {
2734
self::$process[$port]->stop();
2835
} else {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.