Incubated in Java 9, the HTTP Client was standardized in Java 11. This chapter started with an introduction to the HTTP Client API, including the factors that led to its creation. Today's web applications and services should be responsive, supporting asynchronous, non-blocking data transfers. The HTTP Client uses Reactive Streams to achieve these goals.
The HTTP Client can be used to access HTTP resources across the network, using either HTTP/1.1 or HTTP/2, in both synchronous and non-synchronous manners. The HTTP Client API consists of three main classes or interfaces: the HttpClient class, the HttpRequest class, and the HttpResponse interface. The HttpClient class is used to send a request and retrieve the corresponding responses; HttpRequest encapsulates the details of the requested resource, including the request URI. The HttpResponse class encapsulates the response...