261. Getting response information

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(" URI: " + response.uri());
System.out.println(" Status code: " + response.statusCode());
System.out.println(" Headers: " + response.headers());
System.out.println(" Body: " + response.body());

Consider exploring the documentation to find more useful methods.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset