我正在使用来自 Apache Commons 的 HttpClient 对文件发出一个简单的请求。这是我当前的代码:
httpclient = new DefaultHttpClient();
httpget = new HttpGet(location);
context = new BasicHttpContext();
response = httpclient.execute(httpget, context);
entity = response.getEntity();
我需要做什么才能在下载过程中取消此请求?
最佳答案
您可以使用httpget.abort()
方法中途中止请求。
参见示例 here
关于java - 取消 HttpClient 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5400258/