class CommandHelper {

    public static StreamingResponseBody toStreaming(final HystrixCommand<InputStream> command) {
        return outputStream -> {
            final Observable<InputStream> stream = command.toObservable();
            stream.toBlocking().subscribe(inputStream -> {
                try {
                    IOUtils.copyLarge(inputStream, outputStream);
                    outputStream.flush();
                } catch (IOException e) {
                    try {
                        inputStream.close();
                    } catch (IOException closingException) {
                        LOGGER.warn("could not close command result, a http connection may be leaked !",
                                closingException);
                    }
                    LOGGER.error("Unable to fully copy command result '{}'.", command.getClass(), e);
                }
            }, TDPException::rethrowOrWrap);
        };
    }

    private  CommandHelper();

}