Skip to content

AsyncHttpClient

Asynchronous Http and WebSocket Client library for Java

Example

You can also accomplish asynchronous (non-blocking) operation without using a Future if you want to receive and process the response in your handler:

import com.ning.http.client.*;
import java.util.concurrent.Future;

AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
asyncHttpClient.prepareGet("http://www.ning.com/").execute(new AsyncCompletionHandler<Response>(){

    @Override
    public Response onCompleted(Response response) throws Exception{
        // Do something with the Response
        // ...
        return response;
    }

    @Override
    public void onThrowable(Throwable t){
        // Something wrong happened.
    }
});

Dependency

Favorite site