HttpClient超时设置

来源:互联网 发布:断码屏怎么编程 编辑:程序博客网 时间:2024/06/10 06:45

原帖:http://blog.csdn.net/iris0123456/article/details/6535819

DefaultHttpClient:

请求超时
httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 60000); 
读取超时
httpclient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 60000);

HttpClient
HttpClient httpClient=new HttpClient(); 
链接超时
httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(60000);  
读取超时

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



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);

0 0