code: public HttpClient get() {
      final ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager();
      cm.setMaxTotal(nrOfThreads);
      cm.setDefaultMaxPerRoute(maxToRoute);
      final DefaultHttpClient client = HTTPSFaker.getClientThatAllowAnyHTTPS(cm);
  
      client.getParams().setParameter("http.socket.timeout", socketTimeout);
      client.getParams().setParameter("http.connection.timeout", connectionTimeout);
  
      client.addRequestInterceptor(new RequestAcceptEncoding());
      client.addResponseInterceptor(new ResponseContentEncoding());
      
      CookieSpecFactory csf = new CookieSpecFactory() {
        public CookieSpec newInstance(HttpParams params) {
          return new BestMatchSpecWithURLErrorLog();
        }
      };
  
      client.getCookieSpecs().register("bestmatchwithurl", csf);
      client.getParams().setParameter(ClientPNames.COOKIE_POLICY, "bestmatchwithurl");
  
      if (!"".equals(proxy)) {
        StringTokenizer token = new StringTokenizer(proxy, ":");
  
        if (token.countTokens() == 3) {
          String proxyProtocol = token.nextToken();
          String proxyHost = token.nextToken();
          int proxyPort = Integer.parseInt(token.nextToken());
  
          HttpHost proxy = new HttpHost(proxyHost, proxyPort, proxyProtocol);
          client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
        } else
          System.err.println("Invalid proxy configuration: " + proxy);
      }
  
      if (auths.size() > 0) {
  
        for (Auth authObject : auths) {
          client.getCredentialsProvider().setCredentials(
              new AuthScope(authObject.getScope(), authObject.getPort()),
              new UsernamePasswordCredentials(authObject.getUserName(), authObject.getPassword()));
        }
      }
  
      return client;
    }
docs: Get the client.
  
  @return the client