本文整理汇总了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;
}