def _send_chunk(self, data, final):
        # If we don't fit in the connection window, try popping frames off the
        # connection in hope that one might be a window update frame.
        while len(data) > self._out_flow_control_window:
            self._recv_cb()

        # If the length of the data is less than MAX_CHUNK, we're probably
        # at the end of the file. If this is the end of the data, mark it
        # as END_STREAM.
        end_stream = False
        if len(data) < MAX_CHUNK and final:
            end_stream = True

        # Send the frame and decrement the flow control window.
        self._conn.send_data(
            stream_id=self.stream_id, data=data, end_stream=end_stream
        )
        self._send_cb(self._conn.data_to_send())

        if end_stream:
            self.local_closed = True
Implements most of the sending logic.
dataset/ETHPy150Open Lukasa/hyper/hyper/http20/stream.py/Stream._send_chunk