September 2019
Intermediate to advanced
816 pages
18h 47m
English
In order to get information about the response, we can rely on the methods from the HttpResponse class. The names of these methods are very intuitive; therefore, the following snippet of code is self-explanatory:
...HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());System.out.println("Version: " + response.version());System.out.println("\nURI: " + response.uri());System.out.println("\nStatus code: " + response.statusCode());System.out.println("\nHeaders: " + response.headers());System.out.println("\n Body: " + response.body());
Consider exploring the documentation to find more useful methods.