jetty-9: HTTP client: fixed problem when using default ports such as 80 or 443.

This commit is contained in:
Simone Bordet 2012-10-12 12:28:14 +02:00
parent 6159d6f268
commit 7e30c4ac20
2 changed files with 4 additions and 4 deletions

View File

@ -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<Connection> callback)

View File

@ -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())