如何使用HttpClientParams设置时间?
答案 0 :(得分:0)
答案 1 :(得分:0)
这就是我对两个版本的HttpClient使用超时的方法
版本3.1
// create a singular HttpClient object
HttpClient client = new HttpClient();
// establish a connection within 5 seconds
client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
版本4.1.1
// create a singular HttpClient object
DefaultHttpClient client = new DefaultHttpClient();
// get the params for the client
HttpParams params = client.getParams();
// establish a connection within 5 seconds
params.setParameter(CoreConnectionPNames.SO_TIMEOUT, 5000);