I'm modifying a existing project but I see that DefaultAsyncHttpClient
is deprecated. What to replace the deprecated one?
HttpAsyncClient httpclient;
InputStream is = null;
try {
// TODO: deprecated ??
httpclient = new DefaultHttpAsyncClient();
httpclient.start();
try {
// some code
httpclient.shutdown();
}
catch(Exception e) {
}
}
.start()
i cant fetch that method either and neither i can fetch .shutdown
method.
Thank for help!
You can use CloseableHttpAsyncClient , close
instead of shutdown
CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault(); try { httpclient.start(); HttpGet request = new HttpGet("http://httpbin.org/get"); Future<HttpResponse> future = httpclient.execute(request, null); HttpResponse response = future.get(); System.out.println("Response: " + response.getStatusLine()); System.out.println("Shutting down"); } finally { httpclient.close(); }