public ClassicHttpResponse blockWaiting() throws IOException, InterruptedException {
        if (timeout == null) {
            countDownLatch.await();
        } else {
            if (!countDownLatch.await(timeout.getDuration(), timeout.getTimeUnit())) {
                throw new InterruptedIOException("Timeout blocked waiting for input (" + timeout + ")");
            }
        }
        propagateException();
        final ResponseData r = responseRef.getAndSet(null);
        Asserts.notNull(r, "HTTP response is missing");
        final SharedInputBuffer inputBuffer = bufferRef.get();
        return ClassicResponseBuilder.create(r.head.getCode())
                .setHeaders(r.head.getHeaders())
                .setVersion(r.head.getVersion())
                .setEntity(r.entityDetails != null ?
                        new IncomingHttpEntity(new InternalInputStream(inputBuffer), r.entityDetails) :
                        null)
                .build();
    }
TODO: to be replaced by core functionality
httpclient5/src/main/java/org/apache/hc/client5/http/impl/compat/ClassicToAsyncResponseConsumer.java