Index: java/org/apache/commons/httpclient/HttpConnection.java =================================================================== --- java/org/apache/commons/httpclient/HttpConnection.java (revision 157863) +++ java/org/apache/commons/httpclient/HttpConnection.java (working copy) @@ -158,6 +158,8 @@ hostConfiguration.getPort(), hostConfiguration.getProtocol()); this.localAddress = hostConfiguration.getLocalAddress(); + + this.hostConfiguration = hostConfiguration; } /** @@ -1304,6 +1306,10 @@ this.params.setSendBufferSize(sendBufferSize); } + HostConfiguration getHostConfiguration() { + return this.hostConfiguration; + } + // ------------------------------------------------------- Static Variable /** "\r\n", as bytes. */ @@ -1362,4 +1368,6 @@ /** The local interface on which the connection is created, or null for the default */ private InetAddress localAddress; + + private HostConfiguration hostConfiguration; } Index: java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java =================================================================== --- java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java (revision 157863) +++ java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java (working copy) @@ -441,7 +441,7 @@ // we clone the hostConfiguration // so that it cannot be changed once the connection has been retrieved - hostConfiguration = new HostConfiguration(hostConfiguration); + hostConfiguration = (HostConfiguration)hostConfiguration.clone(); HostConnectionPool hostPool = connectionPool.getHostPool(hostConfiguration); WaitingThread waitingThread = null; @@ -629,21 +629,25 @@ * @return a new HostConfiguration */ private HostConfiguration configurationForConnection(HttpConnection conn) { - - HostConfiguration connectionConfiguration = new HostConfiguration(); + HostConfiguration connectionConfiguration = + conn.getHostConfiguration(); - connectionConfiguration.setHost( - conn.getHost(), - conn.getPort(), - conn.getProtocol() - ); - if (conn.getLocalAddress() != null) { - connectionConfiguration.setLocalAddress(conn.getLocalAddress()); + if (connectionConfiguration == null) { + connectionConfiguration = new HostConfiguration(); + + connectionConfiguration.setHost(conn.getHost(), + conn.getPort(), + conn.getProtocol()); + + if (conn.getLocalAddress() != null) { + connectionConfiguration.setLocalAddress(conn.getLocalAddress()); + } + + if (conn.getProxyHost() != null) { + connectionConfiguration.setProxy(conn.getProxyHost(), conn.getProxyPort()); + } } - if (conn.getProxyHost() != null) { - connectionConfiguration.setProxy(conn.getProxyHost(), conn.getProxyPort()); - } - + return connectionConfiguration; }