/**
  * Releases the resources held by the given HTTP client.<br>
  * Note that no further connections can be made upon a disposed HTTP client.
  *
  * @param client the HTTP client to be disposed.
  */
 public static void disposeHttpClient(HttpClient client) {
   if (client != null) {
     ClientConnectionManager manager = client.getConnectionManager();
     manager.shutdown();
     client = null;
   }
 }
Beispiel #2
0
 private void shutdownHttpClient() {
   if (mHttpClient != null) {
     ClientConnectionManager manager = mHttpClient.getConnectionManager();
     if (manager != null) {
       manager.shutdown();
     }
     mHttpClient = null;
   }
 }
  public void release() {
    if (executor != null) {
      executor.shutdown();
    }

    if (connManager != null) {
      connManager.shutdown();
    }

    client = null;
  }
  public void close() {
    if (closed) return;

    if (createdHttpClient && httpClient != null) {
      ClientConnectionManager manager = httpClient.getConnectionManager();
      if (manager != null) {
        manager.shutdown();
      }
    }
    closed = true;
  }
 private static boolean uploader(HttpClient httpClient, HttpPost httpPost) {
   HttpResponse httpResponse;
   ResponseHandler<String> res = new BasicResponseHandler();
   boolean result = false;
   try {
     httpResponse = httpClient.execute(httpPost);
     result = (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK);
     if (result) {
       String response = res.handleResponse(httpResponse).toString();
       result = response.contains("upload success");
     }
   } catch (Exception e) {
   } finally {
     if (httpClient != null) {
       ClientConnectionManager ccm = httpClient.getConnectionManager();
       if (ccm != null) ccm.shutdown();
     }
   }
   return result;
 }
 private static void shutdown(InternalAPI api) {
   ClientConnectionManager connectionManager =
       (ClientConnectionManager) Whitebox.getInternalState(api, "connectionManager");
   connectionManager.shutdown();
 }