首页 > Web开发 > 详细

apache httpclient4 设置超时时间

时间:2015-05-06 11:19:23      阅读:396      评论:0      收藏:0      [点我收藏+]

apache httpclient4 设置超时时间

旧的方法(已被禁用)

CloseableHttpClient httpclient = HttpClients.createDefault();
httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,5000);
httpclient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,5000);

新的方法

HttpPost httppost = new HttpPost(httpUrl);
//设置超时时间为5秒
RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(5000).setConnectTimeout(5000).setSocketTimeout(5000).build();
httppost.setConfig(requestConfig);


apache httpclient4 设置超时时间

原文:http://my.oschina.net/u/914897/blog/411130

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!