Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.58k stars 591 forks source link

Request cancellation (such as download cancellation) #505

Closed SudoDios closed 6 months ago

SudoDios commented 6 months ago

Hi. How to cancel a request ?

ryber commented 6 months ago

You would need to do it async like:

 CompletableFuture<HttpResponse<File>> result = Unirest.get("http://localhost/file")
                .asFileAsync("/path-to-save.txt");

        result.cancel(true);
SudoDios commented 6 months ago

Thank you. But I did not find anything in the document 😅