ProxyClient.ConnectResponse response = client.connect();
socket = response.getSocket();
if (socket == null) {
ConnectMethod method = response.getConnectMethod();
// Read the proxy's HTTP response.
if(method.getStatusLine().toString().matches("HTTP/1\\.\\d 407 Proxy Authentication Required")) {
// Proxy server returned 407. We will now try to connect with auth Header
if(proxyUsername != null && proxyPassword != null) {
socket = AuthenticateProxy(method, client,proxyHost, proxyAddress.getPort(),
proxyUsername, proxyPassword);
} else {
throw new ProtocolException("Socket not created: " + method.getStatusLine());
}
}
}
} catch (Exception e) {