Fixed handling of IPv6 destinations.
This commit is contained in:
parent
8d0c90eef9
commit
5f17509a18
|
@ -55,6 +55,7 @@ public class HttpDestination implements Destination, AutoCloseable, Dumpable
|
|||
private final AtomicInteger connectionCount = new AtomicInteger();
|
||||
private final HttpClient client;
|
||||
private final String scheme;
|
||||
private final String host;
|
||||
private final InetSocketAddress address;
|
||||
private final Queue<RequestContext> requests;
|
||||
private final BlockingQueue<Connection> idleConnections;
|
||||
|
@ -67,6 +68,7 @@ public class HttpDestination implements Destination, AutoCloseable, Dumpable
|
|||
{
|
||||
this.client = client;
|
||||
this.scheme = scheme;
|
||||
this.host = host;
|
||||
this.address = new InetSocketAddress(host, port);
|
||||
this.requests = new ArrayBlockingQueue<>(client.getMaxRequestsQueuedPerDestination());
|
||||
this.idleConnections = new ArrayBlockingQueue<>(client.getMaxConnectionsPerDestination());
|
||||
|
@ -98,7 +100,9 @@ public class HttpDestination implements Destination, AutoCloseable, Dumpable
|
|||
@Override
|
||||
public String getHost()
|
||||
{
|
||||
return address.getHostString();
|
||||
// InetSocketAddress.getHostString() transforms the host string
|
||||
// in case of IPv6 addresses, so we return the original host string
|
||||
return host;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -624,4 +624,18 @@ public class HttpClientTest extends AbstractHttpClientServerTest
|
|||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendToIPv6Address() throws Exception
|
||||
{
|
||||
start(new EmptyServerHandler());
|
||||
|
||||
ContentResponse response = client.newRequest("[::1]", connector.getLocalPort())
|
||||
.scheme(scheme)
|
||||
.send()
|
||||
.get(5, TimeUnit.SECONDS);
|
||||
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue