开发者

Java: stopping long HTTP operations

开发者 https://www.devze.com 2023-01-01 14:09 出处:网络
I\'m using Apache Common library for HTTP operations: HttpClient client = getClient(); PutMethod put = new PutMethod(url);

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

精彩评论

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