Currently the comments for Asynchronous Example in file src/java.net.http/share/classes/java/net/http/HttpClient.java is:
* <p><b>Asynchronous Example</b>
* {@snippet :
* HttpRequest request = HttpRequest.newBuilder()
* .uri(URI.create("https://foo.com/"))
* .timeout(Duration.ofMinutes(2))
* .header("Content-Type", "application/json")
* .POST(BodyPublishers.ofFile(Paths.get("file.json")))
* .build();
* client.sendAsync(request, BodyHandlers.ofString())
* .thenApply(HttpResponse::body)
* .thenAccept(System.out::println); }
It seems that the timeout interface should be connectTimeout(Duration.ofMinutes(2)), rather than timeout(Duration.ofMinutes(2)) ?
* <p><b>Asynchronous Example</b>
* {@snippet :
* HttpRequest request = HttpRequest.newBuilder()
* .uri(URI.create("https://foo.com/"))
* .timeout(Duration.ofMinutes(2))
* .header("Content-Type", "application/json")
* .POST(BodyPublishers.ofFile(Paths.get("file.json")))
* .build();
* client.sendAsync(request, BodyHandlers.ofString())
* .thenApply(HttpResponse::body)
* .thenAccept(System.out::println); }
It seems that the timeout interface should be connectTimeout(Duration.ofMinutes(2)), rather than timeout(Duration.ofMinutes(2)) ?