I am currently using HTTPClient 4 to send a POST request to a remote server as follows:
HttpResponse response = httpClient.execute( request ); InputStream is = response.getEntity().getContent();
When the server is unavailable, it requires battery life before the connection actually expires. During this runtime, execute () is a blocking call.
What I'm looking for is a way to cancel execute () before a natural timeout so that my thread executing execute () no longer blocks and finishes gracefully.
I tried
request.abort();
and
httpClient.getConnectionManager().shutdown();
But both of these calls do not interrupt execution (). Is there any other way to cancel the current connection attempt?
source share