0Pricing
Java Academy · Lesson

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 type T.
  • headers() — response headers.
  • uri() — the final URI (after redirects).
  • version() — HTTP/1.1 or HTTP/2.

All lessons in this course

  1. java.net.http.HttpClient
  2. Async Requests
  3. Request Bodies and Headers
  4. Handling Responses
← Back to Java Academy