How to customise “host” header in Java http client
Here's my code: HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("http://127.0.0.1:8081/")) .header("Host", "test.example.com") .build(); client.send(request, HttpResponse.BodyHandlers.ofString()); As a result I see that the above code sends: GET / HTTP/1.1 Connection: Upgrade, HTTP2-Settings Content-Length: 0 Host: 127.0.0.1:8081 HTTP2-Settings: AAEAAEAAAAIAAAABAAMAAABkAAQBAAAAAAUAAEAA Upgrade: h2c User-Agent: Java-http-client/10 Host: test.example.com As you can see it sends two Host headers (the one from URI and the one I