HttpClient 4 和 HttpClient 3 设置超时

HttpClient 4:

连接超时:

httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,60000);
// 或者
HttpConnectionParams.setConnectionTimeout(params, 6000);

读取超时:

httpclient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,60000);
// 或者
HttpConnectionParams.setSoTimeout(params, 60000);

HttpClient 3:

连接超时:

httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(60000);

读取超时:

httpClient.getHttpConnectionManager().getParams().setSoTimeout(60000);
posted @ 2012-05-28 19:00  星情  阅读(20983)  评论(4编辑  收藏  举报
欢迎阅读旺仔的更多文章:旺仔专栏文章索引