public IORunnable blockWaiting() throws IOException, InterruptedException {
        if (timeout == null) {
            countDownLatch.await();
        } else {
            if (!countDownLatch.await(timeout.getDuration(), timeout.getTimeUnit())) {
                throw new InterruptedIOException("Timeout blocked waiting for output (" + timeout + ")");
            }
        }
        propagateException();
        final SharedOutputBuffer outputBuffer = bufferRef.get();
        return () -> {
            final HttpEntity requestEntity = request.getEntity();
            if (requestEntity != null) {
                try (final InternalOutputStream outputStream = new InternalOutputStream(outputBuffer)) {
                    requestEntity.writeTo(outputStream);
                }
            }
        };
    }
TODO: to be replaced by core functionality
httpclient5/src/main/java/org/apache/hc/client5/http/impl/compat/ClassicToAsyncRequestProducer.java