HTTPCLIENT-1058: SO_TIMEOUT not set early enough for SOCKS proxies

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1070943 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2011-02-15 15:43:48 +00:00
parent a54611e8d6
commit c3c7ba214d
2 changed files with 6 additions and 3 deletions

View File

@ -115,9 +115,12 @@ public class PlainSocketFactory implements SocketFactory, SchemeSocketFactory {
sock.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params));
sock.bind(localAddress);
}
int timeout = HttpConnectionParams.getConnectionTimeout(params);
int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
int soTimeout = HttpConnectionParams.getSoTimeout(params);
try {
sock.connect(remoteAddress, timeout);
sock.setSoTimeout(soTimeout);
sock.connect(remoteAddress, connTimeout);
} catch (SocketTimeoutException ex) {
throw new ConnectTimeoutException("Connect to " + remoteAddress.getHostName() + "/"
+ remoteAddress.getAddress() + " timed out");

View File

@ -371,12 +371,12 @@ public class SSLSocketFactory implements LayeredSchemeSocketFactory, LayeredSock
int soTimeout = HttpConnectionParams.getSoTimeout(params);
try {
sock.setSoTimeout(soTimeout);
sock.connect(remoteAddress, connTimeout);
} catch (SocketTimeoutException ex) {
throw new ConnectTimeoutException("Connect to " + remoteAddress.getHostName() + "/"
+ remoteAddress.getAddress() + " timed out");
}
sock.setSoTimeout(soTimeout);
SSLSocket sslsock;
// Setup SSL layering if necessary
if (sock instanceof SSLSocket) {