---
title: "httpclient"
author: "mistbow"
date: "2013-02-26T10:50:05Z"
tags: []
categories: ["Web前端"]
slug: "httpclient"
draft: false
lastmod: "2013-02-26T10:50:05Z"
id: 1815112
url: "https://mistbow.iteye.com/blog/1815112"
---

```java
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");
	}
```