class ResponseHandlers {

    public static HttpClient.ResponseHandler<byte[]> byteArrayResponseHandler() {
        return (statusCode, responseBody, responseHeaders) -> {
            switch (statusCode) {
                case 200:
                case 201:
                case 202:
                case 204:
                    return toByteArray(responseBody);
                default:
                    throw responseException(statusCode, new PushbackInputStream(responseBody), responseHeaders,
                                            ResponseHandlers::buildEmptyErrorResponse);
            }
        };
    }

    private  ResponseHandlers();

}