public void close() {
    if (closed) return;

    if (createdHttpClient && httpClient != null) {
      ClientConnectionManager manager = httpClient.getConnectionManager();
      if (manager != null) {
        manager.shutdown();
      }
    }
    closed = true;
  }