client.setRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
// establish a connection within x seconds
RequestConfig config = RequestConfig.custom().setSocketTimeout(timeout).build();
client.setDefaultRequestConfig(config);
// no redirects
client.disableRedirectHandling();
// set custom ua
client.setUserAgent(userAgent);
// set the proxy if the user has one set
if ((System.getProperty("http.proxyHost") != null) && (System.getProperty("http.proxyPort") != null)) {
HttpHost proxy = new HttpHost(System.getProperty("http.proxyHost").toString(), Integer.valueOf(System.getProperty("http.proxyPort")));