Why it matters

HttpClient is modern Java HTTP standard. Understanding shapes modern Java networking.

Advertisement

The architecture

HttpClient.newBuilder().build().

HttpRequest built with builder.

send() sync or sendAsync() returns CompletableFuture.

HttpClient APIHttpClientnewBuilder()HttpRequestbuilder patternResponsesync or asyncHTTP/2 by default; WebSocket support built-in
HttpClient usage.
Advertisement

How it works end to end

Body handlers: ofString, ofByteArray, ofFile, ofPublisher for reactive.

Async: CompletableFuture return.

Version: HTTP/1.1 or HTTP/2 (default).

WebSocket: separate API but same client.