Handling Responses
BodyHandlers and status codes.
Handling Responses
Every call to the HTTP client returns an HttpResponse<T>. The generic type T is decided by the BodyHandler you pass in. This lesson explores the available handlers and how to interpret status codes.
The HttpResponse API
Key methods on HttpResponse:
statusCode()— the int status.body()— the decoded body of typeT.headers()— response headers.uri()— the final URI (after redirects).version()— HTTP/1.1 or HTTP/2.
All lessons in this course
- java.net.http.HttpClient
- Async Requests
- Request Bodies and Headers
- Handling Responses