docs: public void flushInternal() throws IOException {
          if (listener == null) {
              if (anyAreSet(state, FLAG_CLOSED)) {
                  //just return
                  return;
              }
              if (buffer != null && buffer.position() != 0) {
                  writeBufferBlocking(false);
              }
              if (channel == null) {
                  channel = servletRequestContext.getExchange().getResponseChannel();
              }
              Channels.flushBlocking(channel);
          } else {
              if (anyAreClear(state, FLAG_READY)) {
                  return;
              }
              createChannel();
              if (buffer == null || buffer.position() == 0) {
                  //nothing to flush, we just flush the underlying stream
                  //it does not matter if this succeeds or not
                  channel.flush();
                  return;
              }
              //we have some data in the buffer, we can just write it out
              //if the write fails we just compact, rather than changing the ready state
              setFlags(FLAG_WRITE_STARTED);
              buffer.flip();
              long res;
              do {
                  res = channel.write(buffer);
              } while (buffer.hasRemaining() && res != 0);
              if (!buffer.hasRemaining()) {
                  channel.flush();
              }
              buffer.compact();
          }
      }