org.apache.hc.client5.http.impl.classic

## Class AbstractHttpClientResponseHandler<T>

- java.lang.Object
- - org.apache.hc.client5.http.impl.classic.AbstractHttpClientResponseHandler<T>

All Implemented Interfaces:
  HttpClientResponseHandler<T>

Direct Known Subclasses:
  BasicHttpClientResponseHandler

    @Contract(threading=STATELESS)
    public abstract class AbstractHttpClientResponseHandler<T>
    extends Object
    implements HttpClientResponseHandler<T>

A generic `HttpClientResponseHandler` that works with the response entity for successful (2xx) responses. If the response code was >= 300, the response body is consumed and an `HttpResponseException` is thrown.

If this is used with `HttpClient.execute( org.apache.hc.core5.http.ClassicHttpRequest, HttpClientResponseHandler)`, HttpClient may handle redirects (3xx responses) internally.

Since:
  4.4

### Constructor Summary

Constructors
Constructor and Description
`AbstractHttpClientResponseHandler()`

### Method Summary

Methods
`abstract T` `handleEntity(HttpEntity entity)` Handle the response entity and transform it into the actual response object.
`T` `handleResponse(ClassicHttpResponse response)` Read the entity from the response body and pass it to the entity handler method if the response was successful (a 2xx status code).

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### AbstractHttpClientResponseHandler

    public AbstractHttpClientResponseHandler()

### Method Detail

#### handleResponse

    public T handleResponse(ClassicHttpResponse response)
                     throws IOException

Read the entity from the response body and pass it to the entity handler method if the response was successful (a 2xx status code). If no response body exists, this returns null. If the response was unsuccessful (>= 300 status code), throws an `HttpResponseException`.

Specified by:
  `handleResponse` in interface `HttpClientResponseHandler<T>`
Throws:
  `IOException`

#### handleEntity

    public abstract T handleEntity(HttpEntity entity)
                            throws IOException

Handle the response entity and transform it into the actual response object.

Throws:
  `IOException`