diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java index a9e86cd0ec4..4230c7f0a11 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java @@ -311,12 +311,11 @@ public class HttpClient extends ContainerLifeCycle if (!Arrays.asList("http", "https").contains(scheme)) throw new IllegalArgumentException("Invalid protocol " + scheme); - String host = request.host().toLowerCase(); int port = request.port(); if (port < 0) port = "https".equals(scheme) ? 443 : 80; - provideDestination(scheme, host, port).send(request, listener); + provideDestination(scheme, request.host(), port).send(request, listener); } protected void newConnection(HttpDestination destination, Callback callback) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java index 85bc87cb127..380d4e1890a 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java @@ -103,8 +103,9 @@ public class HttpDestination implements Destination, AutoCloseable, Dumpable throw new IllegalArgumentException("Invalid request scheme " + request.scheme() + " for destination " + this); if (!host.equals(request.host())) throw new IllegalArgumentException("Invalid request host " + request.host() + " for destination " + this); - if (request.port()>0 && port != request.port()) - throw new IllegalArgumentException("Invalid request port " + request.port() + " for destination " + this); + int port = request.port(); + if (port >= 0 && this.port != port) + throw new IllegalArgumentException("Invalid request port " + port + " for destination " + this); RequestPair requestPair = new RequestPair(request, listener); if (client.isRunning())