@Override
    public Content handleResponse(final ClassicHttpResponse response) throws IOException {
        final int statusCode = response.getCode();
        final HttpEntity entity = response.getEntity();
        final ContentType contentType = (entity != null && entity.getContentType() != null) ? ContentType.parse(entity.getContentType()) : ContentType.DEFAULT_BINARY;
        if (statusCode >= 300) {
            throw new HttpResponseException(statusCode, response.getReasonPhrase(), entity != null ? EntityUtils.toByteArray(entity, MAX_MESSAGE_LENGTH) : null, contentType);
        }
        return new Content(entity != null ? EntityUtils.toByteArray(entity) : new byte[] {}, contentType);
    }
Handles a successful response (2xx status code) and returns the response entity as a {@link Content} object.
If no response entity exists, {@link Content#NO_CONTENT} is returned.

@param response the HTTP response.
@return a {@link Content} object that encapsulates the response body, or {@link Content#NO_CONTENT} if the
response body is {@code null} or has zero length.
@throws HttpResponseException if the response was unsuccessful (status code greater than 300).
@throws IOException           if an I/O error occurs.
httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/ContentResponseHandler.java