I'm experimenting with HTTP/2
client from jdk 9-ea+171
. The code is taken from this example:
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("https://www.google.com/"))
.build();
HttpResponse<String> response
= client.send(request, HttpResponse.BodyHandler.asString());
But the client hangs on the last line forever. Please advice how to fix it?
Debugging shows it infinitely waits in method waitUntilPrefaceSent()
.
newBuilder
that takes aURI
directly, and I usehttp
instead ofhttps
. I get NPE withhttps
. – Felixhttp
because client usesHTTP/1.1
as we can see fromresponse.version()
. I need exactlyhttps
and advantages ofHTTP/2
protocol. – Selfpronouncing