public HttpClient getHttpClient(String hostOrURL, UsernamePasswordCredentials creds) throws IOException, ConnectTimeoutException { String host = null; if (hostOrURL != null) { if (hostOrURL.indexOf("/") != -1) { URL url = new URL(hostOrURL); host = url.getHost(); } else { host = hostOrURL; } } DefaultHttpClient client; if (host != null && creds != null) { client = new PreemptiveAuth(cManager); client.getCredentialsProvider().setCredentials(new AuthScope(host, AuthScope.ANY_PORT), creds); } else { client = new DefaultHttpClient(cManager); } client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, wconfig.getTimeoutSecs() * 1000); client.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, wconfig.getSockTimeoutSecs() * 1000); if (proxy.isHostProxyable(host)) { HttpHost proxyHost = new HttpHost(proxy.getProxyHost(), proxy.getProxyPort(), "http");
public HttpClient getHttpClient(String hostOrURL, UsernamePasswordCredentials creds) throws IOException, ConnectTimeoutException { String host = null; if (hostOrURL != null) { if (hostOrURL.indexOf("/") != -1) { URL url = new URL(hostOrURL); host = url.getHost(); } else { host = hostOrURL; } } DefaultHttpClient client; if (host != null && creds != null) { client = new PreemptiveAuth(cManager); client.getCredentialsProvider().setCredentials(new AuthScope(host, AuthScope.ANY_PORT), creds); } else { client = new DefaultHttpClient(cManager); } client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, wconfig.getTimeoutSecs() * 1000); client.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, wconfig.getSockTimeoutSecs() * 1000); if (proxy.isHostProxyable(host)) { HttpHost proxyHost = new HttpHost(proxy.getProxyHost(), proxy.getProxyPort(), "http");
if (creds != null && creds.getUserName() != null && creds.getUserName().length() > 0) { client = getHttpClient(url, creds); } else { client = getHttpClient(url);
if (creds != null && creds.getUserName() != null && creds.getUserName().length() > 0) { client = getHttpClient(url, creds); } else { client = getHttpClient(url);