18

我正在使用来自 Apache Commons 的 HttpClient 对文件进行简单请求。这是我当前的代码:

    httpclient = new DefaultHttpClient();
    httpget = new HttpGet(location);
    context = new BasicHttpContext();
    response = httpclient.execute(httpget, context);
    entity = response.getEntity();

我需要做什么才能在下载过程中取消此请求?

4

1 回答 1

30

您可以使用httpget.abort()方法中途中止请求。

在此处查看示例

于 2011-03-23T02:44:35.167 回答