Last Updated: June 6, 2026
The HttpURLConnection API works, but it shows its age in every line of calling code. It takes more code to set headers, copy streams, and parse responses than to describe the actual request. Java 11 added a clean replacement in the java.net.http package: HttpClient, HttpRequest, and HttpResponse. This lesson walks through what the new client gives you, when to use sync versus async calls, how the body publishers and handlers fit together, and why one shared client per application is the right shape for production code.
The running example is the same e-commerce backend. We will call product detail APIs, place orders, fan out to several regional inventory services in parallel, retry a flaky CDN, and stream a large image upload.