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


Java HttpClient.getParams方法代碼示例

本文整理匯總了Java中org.apache.http.client.HttpClient.getParams方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpClient.getParams方法的具體用法?Java HttpClient.getParams怎麽用?Java HttpClient.getParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.client.HttpClient的用法示例。


在下文中一共展示了HttpClient.getParams方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getNewHttpClient

import org.apache.http.client.HttpClient; //導入方法依賴的package包/類
public static DefaultHttpClient getNewHttpClient(HttpClient httpClient) {

        try {
            SchemeRegistry registry = new SchemeRegistry();
            ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(registry);
            return new DefaultHttpClient(mgr, httpClient.getParams());
        } catch (Exception ex) {
            return null;
        }

    }
 
開發者ID:NeilRen,項目名稱:NEILREN4J,代碼行數:12,代碼來源:HttpsClientUtils.java

示例2: create

import org.apache.http.client.HttpClient; //導入方法依賴的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

示例3: create

import org.apache.http.client.HttpClient; //導入方法依賴的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


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