public void updateCapacity(final CapacityChannel capacityChannel) throws IOException {
        lock.lock();
        try {
            this.capacityChannel = capacityChannel;
            setInputMode();
            if (buffer().position() == 0) {
                capacityChannel.update(initialBufferSize);
            }
        } finally {
            lock.unlock();
        }
    }
TODO: to be replaced by core functionality
httpclient5/src/main/java/org/apache/hc/client5/http/impl/compat/SharedInputBuffer.java