DataProvider

Callback function invoked when the library wants to read data from the source. The read data is sent in the stream |stream_id|. The implementation of this function must read at most |length| bytes of data from |source| (or possibly other places) and store them in |buf| and return number of data stored in |buf|. If EOF is reached, set DataFlags.EOF

Sometime it is desirable to avoid copying data into |buf| and let application to send data directly. To achieve this, set DataFlags.NO_COPY to |data_flags| (and possibly other flags, just like when we do copy), and return the number of bytes to send without copying data into |buf|. The library, seeing DataFlags.NO_COPY, will invoke Connector.writeData. The application must send complete DATA frame in that callback.

If the application wants to postpone DATA frames (e.g., asynchronous I/O, or reading data blocks for long time), it is achieved by setting pause without reading any data in this invocation. The library removes DATA frame from the outgoing queue temporarily. To move back deferred DATA frame to outgoing queue, call resumeData().

In case of error, there are 2 choices. Setting rst_stream=true will close the stream by issuing RST_STREAM with FrameError.INTERNAL_ERROR. If a different error code is desirable, use http2_submit_rst_stream() with a desired error code and then set rst_stream to true.

Returning false will signal Error.CALLBACK_FAILURE, aborting the entire session.

alias DataProvider = int delegate
(
ubyte[] buf
,)

Meta