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


Java Scheme類代碼示例

本文整理匯總了Java中org.apache.http.conn.scheme.Scheme的典型用法代碼示例。如果您正苦於以下問題:Java Scheme類的具體用法?Java Scheme怎麽用?Java Scheme使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Scheme類屬於org.apache.http.conn.scheme包,在下文中一共展示了Scheme類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getNewHttpClient

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
private static HttpClient getNewHttpClient() { 
   try { 
       KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); 
       trustStore.load(null, null); 

       SSLSocketFactory sf = new SSLSocketFactoryEx(trustStore); 
       sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); 

       HttpParams params = new BasicHttpParams(); 
       HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); 
       HttpProtocolParams.setContentCharset(params, HTTP.UTF_8); 

       SchemeRegistry registry = new SchemeRegistry(); 
       registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); 
       registry.register(new Scheme("https", sf, 443)); 

       ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry); 

       return new DefaultHttpClient(ccm, params); 
   } catch (Exception e) { 
       return new DefaultHttpClient(); 
   } 
}
 
開發者ID:gyqGitHub,項目名稱:WeiXinPayDemo,代碼行數:24,代碼來源:Util.java

示例2: get

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
public static HttpClient get() {
    HttpParams httpParams = new BasicHttpParams();
    ConnManagerParams.setTimeout(httpParams, 3000);
    ConnManagerParams.setMaxConnectionsPerRoute(httpParams, new ConnPerRouteBean(30));
    ConnManagerParams.setMaxTotalConnections(httpParams, 30);
    HttpClientParams.setRedirecting(httpParams, true);
    HttpProtocolParams.setUseExpectContinue(httpParams, true);
    HttpConnectionParams.setStaleCheckingEnabled(httpParams, false);
    HttpConnectionParams.setSoTimeout(httpParams, 2000);
    HttpConnectionParams.setConnectionTimeout(httpParams, 2000);
    HttpConnectionParams.setTcpNoDelay(httpParams, true);
    HttpConnectionParams.setSocketBufferSize(httpParams, 8192);
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme(IDataSource.SCHEME_HTTP_TAG, PlainSocketFactory.getSocketFactory(), 80));
    try {
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null, null);
        SSLSocketFactory sf = new MySSLSocketFactory(trustStore);
        sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        schemeRegistry.register(new Scheme(IDataSource.SCHEME_HTTPS_TAG, sf, 443));
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return new DefaultHttpClient(new ThreadSafeClientConnManager(httpParams, schemeRegistry), httpParams);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:26,代碼來源:PoolingClientConnectionManager.java

示例3: getNewHttpClient

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
private static HttpClient getNewHttpClient() { 
   try { 
       KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
       trustStore.load(null, null); 

       SSLSocketFactory sf = new SSLSocketFactoryEx(trustStore);
       sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

       HttpParams params = new BasicHttpParams();
       HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); 
       HttpProtocolParams.setContentCharset(params, HTTP.UTF_8); 

       SchemeRegistry registry = new SchemeRegistry(); 
       registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); 
       registry.register(new Scheme("https", sf, 443)); 

       ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry); 

       return new DefaultHttpClient(ccm, params); 
   } catch (Exception e) {
       return new DefaultHttpClient(); 
   } 
}
 
開發者ID:cheng2016,項目名稱:developNote,代碼行數:24,代碼來源:HttpUtil.java

示例4: a

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
public static b a(String str) {
    HttpParams basicHttpParams = new BasicHttpParams();
    HttpProtocolParams.setVersion(basicHttpParams, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setUseExpectContinue(basicHttpParams, false);
    HttpConnectionParams.setStaleCheckingEnabled(basicHttpParams, false);
    HttpConnectionParams.setConnectionTimeout(basicHttpParams, 20000);
    HttpConnectionParams.setSoTimeout(basicHttpParams, 30000);
    HttpConnectionParams.setSocketBufferSize(basicHttpParams, 8192);
    HttpClientParams.setRedirecting(basicHttpParams, true);
    HttpClientParams.setAuthenticating(basicHttpParams, false);
    HttpProtocolParams.setUserAgent(basicHttpParams, str);
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    schemeRegistry.register(new Scheme(com.alipay.sdk.cons.b.a, SSLCertificateSocketFactory.getHttpSocketFactory(30000, null), WebSocket.DEFAULT_WSS_PORT));
    ClientConnectionManager threadSafeClientConnManager = new ThreadSafeClientConnManager(basicHttpParams, schemeRegistry);
    ConnManagerParams.setTimeout(basicHttpParams, 60000);
    ConnManagerParams.setMaxConnectionsPerRoute(basicHttpParams, new ConnPerRouteBean(10));
    ConnManagerParams.setMaxTotalConnections(basicHttpParams, 50);
    Security.setProperty("networkaddress.cache.ttl", "-1");
    HttpsURLConnection.setDefaultHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
    return new b(threadSafeClientConnManager, basicHttpParams);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:23,代碼來源:b.java

示例5: getHttpClient

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
/**
 * 每次返回一個新的HttpClient實例
 * @author nan.li
 * @return
 */
public static DefaultHttpClient getHttpClient()
{
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
    schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
    
    PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry);
    cm.setMaxTotal(500);
    cm.setDefaultMaxPerRoute(200);
    
    HttpParams params = new BasicHttpParams();
    params.setParameter("http.connection.timeout", Integer.valueOf(CON_TIMEOUT));
    params.setParameter("http.socket.timeout", Integer.valueOf(SO_TIMEOUT));
    params.setParameter("http.useragent", UA_WINDOW7_CHROME);
    
    DefaultHttpClient client = new DefaultHttpClient(cm, params);
    return client;
}
 
開發者ID:lnwazg,項目名稱:kit,代碼行數:24,代碼來源:HttpConnectionManager.java

示例6: getHttpClient

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
public QMailHttpClient getHttpClient() throws MessagingException {
    if (httpClient == null) {
        httpClient = httpClientFactory.create();
        // Disable automatic redirects on the http client.
        httpClient.getParams().setBooleanParameter("http.protocol.handle-redirects", false);

        // Setup a cookie store for forms-based authentication.
        httpContext = new BasicHttpContext();
        authCookies = new BasicCookieStore();
        httpContext.setAttribute(ClientContext.COOKIE_STORE, authCookies);

        SchemeRegistry reg = httpClient.getConnectionManager().getSchemeRegistry();
        try {
            Scheme s = new Scheme("https", new WebDavSocketFactory(hostname, 443), 443);
            reg.register(s);
        } catch (NoSuchAlgorithmException nsa) {
            Timber.e(nsa, "NoSuchAlgorithmException in getHttpClient");
            throw new MessagingException("NoSuchAlgorithmException in getHttpClient: ", nsa);
        } catch (KeyManagementException kme) {
            Timber.e(kme, "KeyManagementException in getHttpClient");
            throw new MessagingException("KeyManagementException in getHttpClient: ", kme);
        }
    }
    return httpClient;
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:26,代碼來源:WebDavStore.java

示例7: getHttpClient

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
public synchronized static DefaultHttpClient getHttpClient() {
	try {
		HttpParams params = new BasicHttpParams();
		// 設置一些基本參數
		HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
		// 超時設置
		// 從連接池中取連接的超時時間
		ConnManagerParams.setTimeout(params, 10000); // 連接超時
		HttpConnectionParams.setConnectionTimeout(params, 10000); // 請求超時
		HttpConnectionParams.setSoTimeout(params, 30000);
		SchemeRegistry registry = new SchemeRegistry();
		Scheme sch1 = new Scheme("http", PlainSocketFactory
				.getSocketFactory(), 80);
		registry.register(sch1);
		// 使用線程安全的連接管理來創建HttpClient
		ClientConnectionManager conMgr = new ThreadSafeClientConnManager(
				params, registry);
		mHttpClient = new DefaultHttpClient(conMgr, params);
	} catch (Exception e) {
		e.printStackTrace();
	}
	return mHttpClient;
}
 
開發者ID:SShineTeam,項目名稱:Huochexing12306,代碼行數:24,代碼來源:MyHtttpClient.java

示例8: getDefaultSchemeRegistry

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
private static SchemeRegistry getDefaultSchemeRegistry(boolean fixNoHttpResponseException,
                                                       int httpPort, int httpsPort) {
    SSLSocketFactory sslSocketFactory;
    if (fixNoHttpResponseException) {
        Log.d(LOG_TAG, "Beware! Using the fix is insecure, as it doesn't verify SSL " +
                "certificates.");
    }
    if (httpPort < 1) {
        httpPort = 80;
        Log.d(LOG_TAG, "Invalid HTTP port number specified, defaulting to 80");
    }
    if (httpsPort < 1) {
        httpsPort = WebSocket.DEFAULT_WSS_PORT;
        Log.d(LOG_TAG, "Invalid HTTPS port number specified, defaulting to 443");
    }
    if (fixNoHttpResponseException) {
        sslSocketFactory = MySSLSocketFactory.getFixedSocketFactory();
    } else {
        sslSocketFactory = SSLSocketFactory.getSocketFactory();
    }
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(),
            httpPort));
    schemeRegistry.register(new Scheme(b.a, sslSocketFactory, httpsPort));
    return schemeRegistry;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:27,代碼來源:AsyncHttpClient.java

示例9: getInstance

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
/**
 * Returns the one <code>WebServiceUtil</code> instance
 * @return the one <code>WebServiceUtil</code> instance
 */
public static WebServiceUtil getInstance() {
  // This needs to be here instead of in the constructor because
  // it uses classes that are in the AndroidSDK and thus would
  // cause Stub! errors when running the component descriptor.
  synchronized(httpClientSynchronizer) {
    if (httpClient == null) {
      SchemeRegistry schemeRegistry = new SchemeRegistry();
      schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
      schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
      BasicHttpParams params = new BasicHttpParams();
      HttpConnectionParams.setConnectionTimeout(params, 20 * 1000);
      HttpConnectionParams.setSoTimeout(params, 20 * 1000);
      ConnManagerParams.setMaxTotalConnections(params, 20);
      ThreadSafeClientConnManager manager = new ThreadSafeClientConnManager(params,
          schemeRegistry);
      WebServiceUtil.httpClient = new DefaultHttpClient(manager, params);
    }
  }
  return INSTANCE;
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:25,代碼來源:WebServiceUtil.java

示例10: getNewHttpClient

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
/**
 * Gets a DefaultHttpClient which trusts a set of certificates specified by the KeyStore
 *
 * @param keyStore custom provided KeyStore instance
 * @return DefaultHttpClient
 */
public static DefaultHttpClient getNewHttpClient(KeyStore keyStore) {

    try {
        SSLSocketFactory sf = new MySSLSocketFactory(keyStore);
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https", sf, 443));

        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);

        ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);

        return new DefaultHttpClient(ccm, params);
    } catch (Exception e) {
        return new DefaultHttpClient();
    }
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:26,代碼來源:MySSLSocketFactory.java

示例11: getSchemeRegistry

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
public static SchemeRegistry getSchemeRegistry() {
    try {
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null, null);
        SSLSocketFactory.getSocketFactory().setHostnameVerifier(new AllowAllHostnameVerifier());
        SSLSocketFactory sf = new SSLSocketFactory(trustStore);
        sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        HttpParams params = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(params, 10000);
        HttpConnectionParams.setSoTimeout(params, 10000);
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https", sf, 443));
        return registry;
    } catch (Exception e) {
        return null;
    }
}
 
開發者ID:While1true,項目名稱:JSSample,代碼行數:21,代碼來源:HttpUtils.java

示例12: getNewHttpClient

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
/**
 * Gets getUrl DefaultHttpClient which trusts getUrl set of certificates specified by the KeyStore
 *
 * @param keyStore custom provided KeyStore instance
 * @return DefaultHttpClient
 */
public static DefaultHttpClient getNewHttpClient(KeyStore keyStore) {

    try {
        SSLSocketFactory sf = new MySSLSocketFactory(keyStore);
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https", sf, 443));

        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);

        ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);

        return new DefaultHttpClient(ccm, params);
    } catch (Exception e) {
        return new DefaultHttpClient();
    }
}
 
開發者ID:yiwent,項目名稱:Mobike,代碼行數:26,代碼來源:MySSLSocketFactory.java

示例13: setSSLContext

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
public void setSSLContext(final SSLContext sslContext) {
    SchemeRegistry registry = getConnectionManager().getSchemeRegistry();
    registry.unregister("https");
    registry.register(new Scheme("https", 443, new SSLSocketFactory(sslContext)));

    /*
    if (DefaultServer.getHostAddress(DefaultServer.DEFAULT).equals("localhost")) {
        registry.register(new Scheme("https", 443, new SSLSocketFactory(sslContext)));
        registry.register(new Scheme("https", DefaultServer.getHostSSLPort("default"), new SSLSocketFactory(sslContext)));
    } else {
        registry.register(new Scheme("https", 443, new SSLSocketFactory(sslContext, NO_OP_VERIFIER)));
        registry.register(new Scheme("https", DefaultServer.getHostSSLPort("default"), new SSLSocketFactory(sslContext, NO_OP_VERIFIER)));
    }
    */

}
 
開發者ID:networknt,項目名稱:light-session-4j,代碼行數:17,代碼來源:TestHttpClient.java

示例14: init

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
static void init(final NetLayer lowerNetLayer)
	{
		try
		{
			HttpClientUtil.lowerNetLayer = lowerNetLayer;
			final Scheme http = new Scheme("http", new NetlibSocketFactory(lowerNetLayer), 80);

			supportedSchemes = new SchemeRegistry();
			supportedSchemes.register(http);

			// prepare parameters
			final HttpParams httpParams = new BasicHttpParams();
			HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
			HttpProtocolParams.setContentCharset(httpParams, Util.UTF8);
			HttpProtocolParams.setUseExpectContinue(httpParams, true);

//			connMgr = new ThreadSafeClientConnManager(httpParams, supportedSchemes);

		}
		catch (final Exception e)
		{
			LOG.error("error during class init", e);
		}
	}
 
開發者ID:B4dT0bi,項目名稱:silvertunnel-ng,代碼行數:25,代碼來源:HttpClientUtil.java

示例15: createHttpClient

import org.apache.http.conn.scheme.Scheme; //導入依賴的package包/類
private DefaultHttpClient createHttpClient() {
	HttpParams params = new BasicHttpParams();
	HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
	HttpProtocolParams.setContentCharset(params,
			HTTP.DEFAULT_CONTENT_CHARSET);
	HttpProtocolParams.setUseExpectContinue(params, true);
	HttpConnectionParams.setConnectionTimeout(params,
			CONNETED_TIMEOUT * 1000);
	HttpConnectionParams.setSoTimeout(params, CONNETED_TIMEOUT * 1000);
	HttpConnectionParams.setSocketBufferSize(params, 8192);
	ConnManagerParams.setMaxTotalConnections(params, 4);
	SchemeRegistry schReg = new SchemeRegistry();
	schReg.register(new Scheme("http", PlainSocketFactory
			.getSocketFactory(), 80));
	schReg.register(new Scheme("https",
			SSLSocketFactory.getSocketFactory(), 443));

	ClientConnectionManager connMgr = new ThreadSafeClientConnManager(
			params, schReg);

	return new DefaultHttpClient(connMgr, params);
}
 
開發者ID:iQuick,項目名稱:NewsMe,代碼行數:23,代碼來源:M3u8ContentParser.java


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