开发者

Java: stopping long HTTP operations

I'm using Apache Common library for HTTP operations:

HttpClient client = getClient();
PutMethod put = new PutMethod(url);
FileRequestEntity countingFileRequestEntity = n开发者_开发百科ew FileRequestEntity(file, "application/octet-stream");
put.setRequestEntity(countingFileRequestEntity);
client.executeMethod(put);
put.releaseConnection();

I wonder how can safely interrup long HTTP operation. Running it in new thread and stopping it seems to be wrong way. HttpMethodBase has abort() method, but I can't understand how to use it because client.executeMethod blocks execution until it complets


You'll have to run executeMethod() in one thread and call abort() from another one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜