Class PathResponseListener

All Implemented Interfaces:
CompletionStage<PathResponseListener.PathResponse>, Future<PathResponseListener.PathResponse>, EventListener, Response.AsyncContentListener, Response.BeginListener, Response.CompleteListener, Response.ContentListener, Response.ContentSourceListener, Response.FailureListener, Response.HeaderListener, Response.HeadersListener, Response.Listener, Response.ResponseListener, Response.SuccessListener

public class PathResponseListener extends CompletableFuture<PathResponseListener.PathResponse> implements Response.Listener

Implementation of Response.ContentListener that saves the response content to a file Path, like curl <url> -o file.bin does.

Typical usage is:


 // Typical usage.
 httpClient.newRequest(host, port)
     .send(new PathResponseListener(Path.of("/tmp/file.bin")), overwriteExistingFile);

 // Alternative usage.
 var request = httpClient.newRequest(host, port);
 CompletableFuture<PathResponse> completable = PathResponseListener.write(request, Path.of("/tmp/file.bin"), overwriteExistingFile);