本文整理匯總了Java中org.apache.http.impl.conn.SingleClientConnManager類的典型用法代碼示例。如果您正苦於以下問題:Java SingleClientConnManager類的具體用法?Java SingleClientConnManager怎麽用?Java SingleClientConnManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SingleClientConnManager類屬於org.apache.http.impl.conn包,在下文中一共展示了SingleClientConnManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createHttpClient
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
public HttpClient createHttpClient(ClientConfiguration clientconfiguration)
{
BasicHttpParams basichttpparams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(basichttpparams, clientconfiguration.getConnectionTimeout());
HttpConnectionParams.setSoTimeout(basichttpparams, clientconfiguration.getSocketTimeout());
HttpConnectionParams.setStaleCheckingEnabled(basichttpparams, true);
HttpConnectionParams.setTcpNoDelay(basichttpparams, true);
int i = clientconfiguration.getSocketBufferSizeHints()[0];
int j = clientconfiguration.getSocketBufferSizeHints()[1];
if (i > 0 || j > 0)
{
HttpConnectionParams.setSocketBufferSize(basichttpparams, Math.max(i, j));
}
SchemeRegistry schemeregistry = new SchemeRegistry();
schemeregistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
if (clientconfiguration.getProtocol() == Protocol.HTTPS)
{
schemeregistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
}
return new DefaultHttpClient(new SingleClientConnManager(basichttpparams, schemeregistry), basichttpparams);
}
示例2: getHttpClient
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
public static DefaultHttpClient getHttpClient() {
try {
HttpsURLConnection.setDefaultHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
trustStore.load(null, null);
SSLSocketFactory socketFactory = new MySSLSocketFactory(trustStore);
socketFactory.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
BasicHttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
HttpConnectionParams.setConnectionTimeout(params, 10000);
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
registry.register(new Scheme("https", socketFactory, 443));
SingleClientConnManager mgr = new SingleClientConnManager(params, registry);
return new DefaultHttpClient(mgr, params);
}
catch(Exception e) {
Log.e("DumpsterMap", "Unable to create custom DefaultHttpClient.", e);
}
return new DefaultHttpClient();
}
示例3: createHttpClient
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
public static DefaultHttpClient createHttpClient(HostnameVerifierType p_verifierType) {
if (p_verifierType != null && p_verifierType != HostnameVerifierType.DEFAULT) {
switch (p_verifierType) {
case ALLOW_ALL:
HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
DefaultHttpClient client = new DefaultHttpClient();
SchemeRegistry registry = new SchemeRegistry();
SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
registry.register(new Scheme("https", socketFactory, 443));
SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
// Set verifier
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
return new DefaultHttpClient(mgr, client.getParams());
case DEFAULT:
return new DefaultHttpClient();
}
}
return new DefaultHttpClient();
}
示例4: create
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
/**
* HTTPClientオブジェクトを作成.
* @param type 通信タイプ
* @return 作成したHttpClientクラスインスタンス
*/
public static HttpClient create(final String type) {
if (TYPE_DEFAULT.equalsIgnoreCase(type)) {
return new DefaultHttpClient();
}
SSLSocketFactory sf = null;
try {
if (TYPE_INSECURE.equalsIgnoreCase(type)) {
sf = createInsecureSSLSocketFactory();
}
} catch (Exception e) {
return null;
}
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("https", PORTHTTPS, sf));
schemeRegistry.register(new Scheme("http", PORTHTTP, PlainSocketFactory.getSocketFactory()));
HttpParams params = new BasicHttpParams();
ClientConnectionManager cm = new SingleClientConnManager(schemeRegistry);
// ClientConnectionManager cm = new
// ThreadSafeClientConnManager(schemeRegistry);
HttpClient hc = new DefaultHttpClient(cm, params);
HttpParams params2 = hc.getParams();
int timeout = TIMEOUT;
HttpConnectionParams.setConnectionTimeout(params2, timeout); // 接続のタイムアウト
HttpConnectionParams.setSoTimeout(params2, timeout); // データ取得のタイムアウト
return hc;
}
示例5: create
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
/**
* HTTPClientオブジェクトを作成.
* @param type 通信タイプ
* @param connectionTimeout タイムアウト値(ミリ秒)。0の場合はデフォルト値を利用する。
* @return 作成したHttpClientクラスインスタンス
*/
public static HttpClient create(final String type, final int connectionTimeout) {
if (TYPE_DEFAULT.equalsIgnoreCase(type)) {
return new DefaultHttpClient();
}
SSLSocketFactory sf = null;
try {
if (TYPE_INSECURE.equalsIgnoreCase(type)) {
sf = createInsecureSSLSocketFactory();
}
} catch (Exception e) {
return null;
}
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("https", PORTHTTPS, sf));
schemeRegistry.register(new Scheme("http", PORTHTTP, PlainSocketFactory.getSocketFactory()));
HttpParams params = new BasicHttpParams();
ClientConnectionManager cm = new SingleClientConnManager(schemeRegistry);
// ClientConnectionManager cm = new
// ThreadSafeClientConnManager(schemeRegistry);
HttpClient hc = new DefaultHttpClient(cm, params);
HttpParams params2 = hc.getParams();
int timeout = TIMEOUT;
if (connectionTimeout != 0) {
timeout = connectionTimeout;
}
HttpConnectionParams.setConnectionTimeout(params2, timeout); // 接続のタイムアウト
HttpConnectionParams.setSoTimeout(params2, timeout); // データ取得のタイムアウト
return hc;
}
示例6: createHttpsClient
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
private static HttpClient createHttpsClient() {
HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
SchemeRegistry registry = new SchemeRegistry();
SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
socketFactory
.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
registry.register(new Scheme("https", socketFactory, 443));
HttpClient client = new DefaultHttpClient();
SingleClientConnManager mgr = new SingleClientConnManager(
client.getParams(), registry);
DefaultHttpClient httpClient = new DefaultHttpClient(mgr,
client.getParams());
return httpClient;
}
示例7: createClientConnectionManager
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
@Override
protected ClientConnectionManager createClientConnectionManager() {
NextGenLogger.d(F.TAG, "SecureFlxHttpClient.createClientConnectionManager");
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(), 443));
return new SingleClientConnManager(getParams(), schemeRegistry);
}
示例8: GpsDataFixer
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
public GpsDataFixer() {
final SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", new PlainSocketFactory(), 80));
final ClientConnectionManager connexionManager = new SingleClientConnManager(null, registry);
final HttpClient httpClient = new DefaultHttpClient(connexionManager, null);
nominatimClient = new JsonNominatimClient(httpClient, "[email protected]");
}
示例9: createClientConnectionManager
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
@Override
protected ClientConnectionManager createClientConnectionManager() {
SchemeRegistry registry = new SchemeRegistry();
registry.register(
new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
registry.register(new Scheme("https", new EasySSLSocketFactory(), 443));
return new SingleClientConnManager(getParams(), registry);
}
示例10: createClientConnectionManager
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
private ClientConnectionManager createClientConnectionManager(
boolean threadSafe) {
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory
.getSocketFactory(), HTTP_PORT_DEFAULT));
schemeRegistry.register(new Scheme("https", m_sslSocketFactory,
HTTPS_PORT_DEFAULT));
if (threadSafe) {
return new ThreadSafeClientConnManager(sm_httpParams,
schemeRegistry);
} else {
return new SingleClientConnManager(sm_httpParams, schemeRegistry);
}
}
示例11: createClientConnectionManager
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
private ClientConnectionManager createClientConnectionManager(boolean threadSafe) {
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), HTTP_PORT_DEFAULT));
schemeRegistry.register(new Scheme("https", m_sslSocketFactory, HTTPS_PORT_DEFAULT));
if (threadSafe) {
return new ThreadSafeClientConnManager(sm_httpParams, schemeRegistry);
} else {
return new SingleClientConnManager(sm_httpParams, schemeRegistry);
}
}
示例12: createClientConnectionManager
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
@Override protected ClientConnectionManager createClientConnectionManager() {
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
registry.register(new Scheme("https", newSslSocketFactory(), 443));
return new SingleClientConnManager(getParams(), registry);
//return new ThreadSafeClientConnManager(getParams(), registry);
}
示例13: createClientConnectionManager
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
@Override protected ClientConnectionManager createClientConnectionManager() {
SchemeRegistry registry = new SchemeRegistry();
registry.register(
new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
registry.register(new Scheme("https", newSslSocketFactory(), 443));
return new SingleClientConnManager(getParams(), registry);
}
示例14: createClientConnectionManager
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
@Override
protected ClientConnectionManager createClientConnectionManager()
{
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
// Register for port 443 our SSLSocketFactory with our keystore
// to the ConnectionManager
//TODO registry.register(new Scheme("https", newSslSocketFactory(), 443));
return new SingleClientConnManager(getParams(), registry);
}
示例15: createClientConnectionManager
import org.apache.http.impl.conn.SingleClientConnManager; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
protected ClientConnectionManager createClientConnectionManager() {
if (resourceId != 0) {
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory
.getSocketFactory(), 80));
registry.register(new Scheme("https", createSslSocketFactory(), 443));
registry.register(new Scheme("https", createSslSocketFactory(),
8443));
return new SingleClientConnManager(getParams(), registry);
} else {
return super.createClientConnectionManager();
}
}