mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-16 23:16:33 +00:00
Added option to create fluent Executor on top of an arbitrary HttpClient instance
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1243662 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eac4ae43a7
commit
fdeb405065
@ -42,6 +42,8 @@
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.client.protocol.ClientContext;
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import org.apache.http.conn.ssl.SSLInitializationException;
|
||||
import org.apache.http.impl.auth.BasicScheme;
|
||||
import org.apache.http.impl.client.BasicAuthCache;
|
||||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
@ -56,8 +58,13 @@ public class Executor {
|
||||
final static DefaultHttpClient CLIENT;
|
||||
|
||||
static {
|
||||
CONNMGR = new PoolingClientConnectionManager(
|
||||
SchemeRegistryFactory.createSystemDefault());
|
||||
SchemeRegistry schemeRegistry;
|
||||
try {
|
||||
schemeRegistry = SchemeRegistryFactory.createSystemDefault();
|
||||
} catch (SSLInitializationException ex) {
|
||||
schemeRegistry = SchemeRegistryFactory.createDefault();
|
||||
}
|
||||
CONNMGR = new PoolingClientConnectionManager(schemeRegistry);
|
||||
CONNMGR.setDefaultMaxPerRoute(100);
|
||||
CONNMGR.setMaxTotal(200);
|
||||
CLIENT = new DefaultHttpClient(CONNMGR);
|
||||
@ -67,6 +74,10 @@ public static Executor newInstance() {
|
||||
return new Executor(CLIENT);
|
||||
}
|
||||
|
||||
public static Executor newInstance(final HttpClient httpclient) {
|
||||
return new Executor(httpclient != null ? httpclient : CLIENT);
|
||||
}
|
||||
|
||||
private final HttpClient httpclient;
|
||||
private final BasicHttpContext localContext;
|
||||
private final AuthCache authCache;
|
||||
|
Loading…
x
Reference in New Issue
Block a user