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


Java MultiThreadedHttpConnectionManager.getParams方法代碼示例

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


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

示例1: init

import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
/**
 * 
 * @throws Exception .
 */
private void init() throws Exception {
    httpClientManager = new MultiThreadedHttpConnectionManager();
  
    HttpConnectionManagerParams params = httpClientManager.getParams();
    params.setStaleCheckingEnabled(true);
    params.setMaxTotalConnections(1000);
    params.setDefaultMaxConnectionsPerHost(500);
    params.setConnectionTimeout(2000);
    params.setSoTimeout(3000);
 
    /** 設置從連接池中獲取連接超時。*/
    HttpClientParams clientParams  = new HttpClientParams();
    clientParams.setConnectionManagerTimeout(1000);
    httpClient = new HttpClient(clientParams, httpClientManager);
    
}
 
開發者ID:magenm,項目名稱:bsming,代碼行數:21,代碼來源:HttpClientUtil.java

示例2: initialize

import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
private void initialize(Cluster cluster, boolean sslEnabled) {
  this.cluster = cluster;
  this.sslEnabled = sslEnabled;
  MultiThreadedHttpConnectionManager manager =
    new MultiThreadedHttpConnectionManager();
  HttpConnectionManagerParams managerParams = manager.getParams();
  managerParams.setConnectionTimeout(2000); // 2 s
  managerParams.setDefaultMaxConnectionsPerHost(10);
  managerParams.setMaxTotalConnections(100);
  extraHeaders = new ConcurrentHashMap<String, String>();
  this.httpClient = new HttpClient(manager);
  HttpClientParams clientParams = httpClient.getParams();
  clientParams.setVersion(HttpVersion.HTTP_1_1);

}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:16,代碼來源:Client.java

示例3: HttpClient

import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
public HttpClient(int maxConPerHost, int conTimeOutMs, int soTimeOutMs,
		int maxSize) {
	connectionManager = new MultiThreadedHttpConnectionManager();
	HttpConnectionManagerParams params = connectionManager.getParams();
	params.setDefaultMaxConnectionsPerHost(maxConPerHost);
	params.setConnectionTimeout(conTimeOutMs);
	params.setSoTimeout(soTimeOutMs);

	HttpClientParams clientParams = new HttpClientParams();
	// 忽略cookie 避免 Cookie rejected 警告
	clientParams.setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
	client = new org.apache.commons.httpclient.HttpClient(clientParams,
			connectionManager);
	Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443);
	Protocol.registerProtocol("https", myhttps);
	this.maxSize = maxSize;
	// 支持proxy
	if (proxyHost != null && !proxyHost.equals("")) {
		client.getHostConfiguration().setProxy(proxyHost, proxyPort);
		client.getParams().setAuthenticationPreemptive(true);
		if (proxyAuthUser != null && !proxyAuthUser.equals("")) {
			client.getState().setProxyCredentials(
					AuthScope.ANY,
					new UsernamePasswordCredentials(proxyAuthUser,
							proxyAuthPassword));
			log("Proxy AuthUser: " + proxyAuthUser);
			log("Proxy AuthPassword: " + proxyAuthPassword);
		}
	}
}
 
開發者ID:seagrape,項目名稱:kekoa,代碼行數:31,代碼來源:HttpClient.java

示例4: Client

import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
/**
 * Constructor
 * @param cluster the cluster definition
 */
public Client(Cluster cluster) {
  this.cluster = cluster;
  MultiThreadedHttpConnectionManager manager = 
    new MultiThreadedHttpConnectionManager();
  HttpConnectionManagerParams managerParams = manager.getParams();
  managerParams.setConnectionTimeout(2000); // 2 s
  managerParams.setDefaultMaxConnectionsPerHost(10);
  managerParams.setMaxTotalConnections(100);
  extraHeaders = new ConcurrentHashMap<String, String>();
  this.httpClient = new HttpClient(manager);
  HttpClientParams clientParams = httpClient.getParams();
  clientParams.setVersion(HttpVersion.HTTP_1_1);
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:18,代碼來源:Client.java

示例5: createHttpClient

import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
public static HttpClient createHttpClient() {
	HttpClient result = null;
	try {

		result = new HttpClient();
		// 使用多緒HttpClient
		MultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager();
		HttpConnectionManagerParams managerParams = httpConnectionManager
				.getParams();
		managerParams.setDefaultMaxConnectionsPerHost(100);
		managerParams.setMaxTotalConnections(200);
		// 連線超時
		managerParams.setConnectionTimeout(5 * 1000);
		// 讀取超時
		managerParams.setSoTimeout(5 * 1000);
		//
		result.setHttpConnectionManager(httpConnectionManager);
		//
		HttpClientParams params = result.getParams();
		// http.protocol.content-charset
		params.setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
		// 失敗 retry 3 次
		params.setParameter(HttpMethodParams.RETRY_HANDLER,
				new DefaultHttpMethodRetryHandler(3, false));

	} catch (Exception ex) {
		ex.printStackTrace();
	}
	return result;
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:31,代碼來源:BenchmarkHttpClient3Test.java

示例6: Client

import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
/**
 * Constructor
 * @param cluster the cluster definition
 */
public Client(Cluster cluster) {
  this.cluster = cluster;
  MultiThreadedHttpConnectionManager manager = 
    new MultiThreadedHttpConnectionManager();
  HttpConnectionManagerParams managerParams = manager.getParams();
  managerParams.setConnectionTimeout(2000); // 2 s
  managerParams.setDefaultMaxConnectionsPerHost(10);
  managerParams.setMaxTotalConnections(100);
  this.httpClient = new HttpClient(manager);
  HttpClientParams clientParams = httpClient.getParams();
  clientParams.setVersion(HttpVersion.HTTP_1_1);
}
 
開發者ID:lifeng5042,項目名稱:RStore,代碼行數:17,代碼來源:Client.java

示例7: MultithreadedDownloader

import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
MultithreadedDownloader(int threads) {
    this.threads = threads;
    MultiThreadedHttpConnectionManager conMgr = new MultiThreadedHttpConnectionManager();
    HostConfiguration hc = new HostConfiguration();
    HttpConnectionManagerParams params = conMgr.getParams();
    params.setMaxConnectionsPerHost(hc, 10);
    httpClient = new HttpClient(conMgr);
    httpClient.setHostConfiguration(hc);
}
 
開發者ID:mimacom,項目名稱:maven-liferay-plugin,代碼行數:10,代碼來源:MultithreadedDownloader.java

示例8: setUp

import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    super.setUp();
    MultiThreadedHttpConnectionManager connManag =  new MultiThreadedHttpConnectionManager();

    HttpConnectionManagerParams managParams = connManag.getParams();

    managParams.setConnectionTimeout(10000); // 1
    managParams.setSoTimeout(10000); //2
    client = new HttpClient(connManag);
    client.getParams().setParameter("http.connection-manager.timeout", new Long(10000)); //3


}
 
開發者ID:DovAmir,項目名稱:httpclientAuthHelper,代碼行數:15,代碼來源:AuthUtilsTest.java

示例9: HttpClient

import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
public HttpClient(int maxConPerHost, int conTimeOutMs, int soTimeOutMs,
		int maxSize) {
	connectionManager = new MultiThreadedHttpConnectionManager();
	HttpConnectionManagerParams params = connectionManager.getParams();
	params.setDefaultMaxConnectionsPerHost(maxConPerHost);
	params.setConnectionTimeout(conTimeOutMs);
	params.setSoTimeout(soTimeOutMs);

	HttpClientParams clientParams = new HttpClientParams();
	clientParams.setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
	client = new org.apache.commons.httpclient.HttpClient(clientParams, connectionManager);
	Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443);
	Protocol.registerProtocol("https", myhttps);
}
 
開發者ID:wangpeile,項目名稱:mx-connector-1.5,代碼行數:15,代碼來源:HttpClient.java


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