是一种将连接拒绝时间设置为 HTTPGet Apache 的方法吗?
Is a way to set Connection refused time to HTTPGet Apache ?
我想获取一个网页,但如果 return 连接被拒绝,我只想等待 1 秒
我的代码:
final DefaultHttpClient client = HTTPSHelper.getClientThatAllowAnyHTTPS(connectionManager);
client.getParams().setParameter(ClientPNames.COOKIE_POLICY,
CookiePolicy.BROWSER_COMPATIBILITY);
client.getParams().setParameter("http.socket.timeout", 1000);
client.getParams().setParameter("http.connection.timeout", 1000);
client.addRequestInterceptor(new RequestAcceptEncoding());
client.addResponseInterceptor(new ResponseContentEncoding());
final HttpGet get = new HttpGet(url.getUrl());
final HttpResponse resp = this.httpClient.execute(get, localContext);
当 returns 连接被拒绝时,我必须等待很多时间...有没有办法指定等待连接被拒绝的时间?谢谢
您可以这样设置连接超时:
final HttpParams p = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(p, 1000);
client = new DefaultHttpClient(httpParams) ;
我想获取一个网页,但如果 return 连接被拒绝,我只想等待 1 秒
我的代码:
final DefaultHttpClient client = HTTPSHelper.getClientThatAllowAnyHTTPS(connectionManager);
client.getParams().setParameter(ClientPNames.COOKIE_POLICY,
CookiePolicy.BROWSER_COMPATIBILITY);
client.getParams().setParameter("http.socket.timeout", 1000);
client.getParams().setParameter("http.connection.timeout", 1000);
client.addRequestInterceptor(new RequestAcceptEncoding());
client.addResponseInterceptor(new ResponseContentEncoding());
final HttpGet get = new HttpGet(url.getUrl());
final HttpResponse resp = this.httpClient.execute(get, localContext);
当 returns 连接被拒绝时,我必须等待很多时间...有没有办法指定等待连接被拒绝的时间?谢谢
您可以这样设置连接超时:
final HttpParams p = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(p, 1000);
client = new DefaultHttpClient(httpParams) ;