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.
精彩评论