欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

httpclient  

程序员文章站 2022-07-14 12:36:24
...
private static MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
	private static HttpClient client = new HttpClient(connectionManager);


static {
		client.getHttpConnectionManager().getParams()
				.setConnectionTimeout(30000);
		client.getHttpConnectionManager().getParams().setSoTimeout(30000);
		client.getHttpConnectionManager().getParams()
				.setDefaultMaxConnectionsPerHost(8);
		client.getHttpConnectionManager().getParams()
				.setMaxTotalConnections(48);
		client.getHttpConnectionManager()
				.getParams()
				.setParameter(HttpMethodParams.RETRY_HANDLER,
						new DefaultHttpMethodRetryHandler());
		client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,
				"UTF-8");
	}