// This connection manager must be used if more than one thread will
// be using the HttpClient.
ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
HttpClient httpClient = new DefaultHttpClient(cm, params);
final ClientHttpEngine executor;
if (clazz.isAssignableFrom(ApacheHttpClient4Engine.class)) {
executor = new ApacheHttpClient4Engine(httpClient);
} else {
executor = new URLConnectionEngine();