March 2019
Intermediate to advanced
242 pages
6h 21m
English
When you send an HttpRequest instance using an HttpClient instance, you receive HttpResponse. Upon sending an HTTP request, a server typically returns the status code of the response, the response header, and the response body.
So, when can you access the response body? It depends on the BodyHandler that you specify to be used, when you send the request using the HttpClient send() or sendAsync() methods. Depending on the specified BodyHandler, you might be able to access the response body after the response status code and header are available (and before the response body is made available).
Let's revisit the first example from this chapter:
HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() ...
Read now
Unlock full access