Example #1
0
  private HttpUtility() {

    HttpParams params = new BasicHttpParams();
    params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
    PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
    connectionManager.setMaxTotal(5);

    httpClient = new DecompressingHttpClient(new DefaultHttpClient(connectionManager));
    HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), 8000);
    HttpConnectionParams.setSoTimeout(httpClient.getParams(), 8000);
  }
 /**
  * Sets the connection time oout. By default, 10 seconds
  *
  * @param timeout the connect/socket timeout in milliseconds
  */
 public void setTimeout(int timeout) {
   final HttpParams httpParams = this.cachingHttpClient.getParams();
   ConnManagerParams.setTimeout(httpParams, timeout);
   HttpConnectionParams.setSoTimeout(httpParams, timeout);
   HttpConnectionParams.setConnectionTimeout(httpParams, timeout);
 }