You can use the Jetty 9 HttpClient documentation as a reference.
The long answer to your question is explained here , the Response Content Handling section.
If you pass a simple CompleteListener to Request.send(CompleteListener) , it means that you are not interested in the content that will be thrown.
If you are interested in the content, but only at the end of the response, you can pass the provided utility classes, such as the BufferingResponseListener :
request.send(new BufferingResponseListener() { ... });
If you are interested in the content as it arrives, you should pass a Response.ContentListener , which will notify you of the content fragment in a block.
You can do this in two ways: using Response.Listener (which extends Response.ContentListener ):
request.send(new Response.Listener() { public void onContent(...) { ... } public void onComplete(...) { ... } });
or using multiple listeners:
request.onResponseContent(new Response.ContentListener() { ... }); request.send(new CompleteListener() { ... });
You have everything you need and ready-made utility classes that help you (no need to write complex buffering code, just use the BufferingResponseListener ).
source share