March 2019
Intermediate to advanced
242 pages
6h 21m
English
To request an HTTP resource over the network, you'll need to call either of the methods send() or sendAsync() on the HttpClient instance. The send() method sends a request and receives its response synchronously; it will block until these tasks are not complete. The method sendAsync() communicates with a server asynchronously; it sends a request and immediately returns with CompletableFuture.
Before I include examples of the send() and sendAsync() methods, it is important to understand the other two classes: HttpRequest and HttpResponse. I'll cover these methods (send() and sendAsync()) in the section on HttpResponse.
Here's a quick list of the important methods of the HttpClient class:
|
Method Return Type ... |
Read now
Unlock full access