/** * Creates a new HTTP connection for the given host configuration. * * @param hostConfiguration the host/proxy/protocol to use */ public HttpConnection(HostConfiguration hostConfiguration) { this( hostConfiguration.getProxyHost(), hostConfiguration.getProxyPort(), hostConfiguration.getHost(), hostConfiguration.getPort(), hostConfiguration.getProtocol()); this.localAddress = hostConfiguration.getLocalAddress(); }
public HttpConnection getConnection(HostConfiguration hostConfiguration) { // make sure the host and proxy are correct for this connection // close it and set the values if they are not if (!hostConfiguration.hostEquals(connection) || !hostConfiguration.proxyEquals(connection)) { if (connection.isOpen()) { connection.close(); } connection.setHost(hostConfiguration.getHost()); connection.setPort(hostConfiguration.getPort()); connection.setProtocol(hostConfiguration.getProtocol()); connection.setLocalAddress(hostConfiguration.getLocalAddress()); connection.setProxyHost(hostConfiguration.getProxyHost()); connection.setProxyPort(hostConfiguration.getProxyPort()); } else { finishLastResponse(connection); } connectionReleased = false; return connection; }