@Override
    public T handleResponse(final ClassicHttpResponse response) throws IOException {
        final HttpEntity entity = response.getEntity();
        if (response.getCode() >= HttpStatus.SC_REDIRECTION) {
            EntityUtils.consume(entity);
            throw new HttpResponseException(response.getCode(), response.getReasonPhrase());
        }
        return entity == null ? null : handleEntity(entity);
    }
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 (&gt;= 300
status code), throws an {@link HttpResponseException}.
httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/AbstractHttpClientResponseHandler.java