本文整理匯總了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;
}
}
示例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;
}
示例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;
}