static HttpResponse createHttpResponseFrom(CompletableFuture<? extends HttpResponse> future) {
        requireNonNull(future, "future");

        if (future.isDone()) {
            if (!future.isCompletedExceptionally()) {
                return future.getNow(null);
            }

            try {
                future.join();
                // Should never reach here.
                throw new Error();
            } catch (Throwable cause) {
                return HttpResponse.ofFailure(Exceptions.peel(cause));
            }
        }

        final DeferredHttpResponse res = new DeferredHttpResponse();
        res.delegateWhenComplete(future);
        return res;
    }
Creates a new HTTP response that delegates to the {@link HttpResponse} produced by the specified
{@link CompletableFuture}. If the specified {@link CompletableFuture} fails, the returned response
will be closed with the same cause as well.

@param future the {@link CompletableFuture} which will produce the actual {@link HttpResponse}
core/src/main/java/com/linecorp/armeria/common/HttpResponseUtil.java