我想在我的项目中更新httpclient版本.项目现在使用http 3.1 jar我需要升级4.0版本.我从
here下载了存储库
我改变了大部分代码,但坚持使用一些api和方法.我用google搜索了很多但却无法找到相应的代码,我在下面描述:
MultiThreadedhttpconnectionManager的等效性是多少?
我找到了用于httpClient 4.x的PoolingClientConnectionManager,但它在4.0版本中不存在.
这是我对httpversion 3.1的旧代码库
MultiThreadedhttpconnectionManager connMgr = new MultiThreadedhttpconnectionManager();
m_client = new HttpClient(connMgr);
/*
* Maximum concurrent connections that are allowed to a given
* domain/host
*/
m_client.gethttpconnectionManager()
.getParams()
.setMaxConnectionsPerHost(
HostConfiguration.ANY_HOST_CONfigURATION,maxConcurrentConnections);
/*
*
* How long to wait before timing out on a http connection
*/
m_client.gethttpconnectionManager().getParams()
.setConnectionTimeout(connectionTimeout);
/*
* How long to wait before timing out on a socket connection
*/
m_client.getParams().setSoTimeout(socketTimeout);
解决方法
看起来httpclient 4.0使用了
ThreadSafeClientConnManager,在版本4.2中不推荐使用
PoolingClientConnectionManager.
我在下面的帖子中找到了这个:Best Practice to Use HttpClient in Multithreaded Environment