當前位置: 首頁>>代碼示例>>Java>>正文


Java SingleClientConnManager類代碼示例

本文整理匯總了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);
}
 
開發者ID:vishnudevk,項目名稱:MiBandDecompiled,代碼行數:22,代碼來源:HttpAndroidClientFactory.java

示例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();
}
 
開發者ID:ShadowedMists,項目名稱:DumpsterMapAndroid,代碼行數:27,代碼來源:HttpsUtil.java

示例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();
}
 
開發者ID:GluuFederation,項目名稱:oxAuth,代碼行數:24,代碼來源:BaseTest.java

示例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;
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:35,代碼來源:HttpClientFactory.java

示例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;
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:39,代碼來源:HttpClientFactory.java

示例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;
}
 
開發者ID:zsavvas,項目名稱:ReCRED_FIDO_UAF_OIDC,代碼行數:15,代碼來源:Curl.java

示例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);
}
 
開發者ID:warnerbros,項目名稱:cpe-manifest-android-experience,代碼行數:9,代碼來源:SecureFlxHttpClient.java

示例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]");
}
 
開發者ID:gov-ithub,項目名稱:infotranspub-backend,代碼行數:10,代碼來源:GpsDataFixer.java

示例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);
}
 
開發者ID:benjamarle,項目名稱:typhon,代碼行數:9,代碼來源:TyphonModuleDagger.java

示例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);
	}
}
 
開發者ID:tommy4711,項目名稱:gaeproxy,代碼行數:15,代碼來源:WeaveTransport.java

示例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);
  }
}
 
開發者ID:mashiwoo,項目名稱:zirco-browser,代碼行數:11,代碼來源:WeaveTransport.java

示例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);
}
 
開發者ID:adaptationdev,項目名稱:AndroidAuth,代碼行數:8,代碼來源:ServerCertHttpClient.java

示例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);
}
 
開發者ID:Nikhil-Nandagopal,項目名稱:EasyRestClient,代碼行數:8,代碼來源:EasySecureHttpClient.java

示例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);
}
 
開發者ID:vocefiscal,項目名稱:vocefiscal-android,代碼行數:11,代碼來源:MyHttpClient.java

示例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();
	}
}
 
開發者ID:kautsig,項目名稱:humbleshare-app,代碼行數:18,代碼來源:TrustingHttpClient.java


注:本文中的org.apache.http.impl.conn.SingleClientConnManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。