With the HTTP Client API, your Java code can request HTTP resources over the network, using the HTTP/2 protocol, in a non-blocking and asynchronous way. It brings major improvements to the existing HttpURLConnection class, which was added to Java in Version 1.1, and only works in a blocking and synchronous way.
The HTTP Client was incubated in Java 9, with multiple modifications in Java 10, and was standardized in Java 11. It resides in the java.net.http package and module.
In this chapter, we'll cover the following topics:
- An introduction to the HTTP Client
- Sending requests synchronously and asynchronously
- Converting response bytes to high-level formats
- Using Reactive Streams to handle HTTP requests and responses
- BodyHandler, BodyPublisher, and BodySubscriber