Connector

Undocumented in source.

Members

Functions

maxFrameSize
int maxFrameSize(FrameType frame_type, int stream_id, int session_remote_window_size, int stream_remote_window_size, uint remote_max_frame_size)

Callback function invoked when library wants to get max length of data to send data to the remote peer. The implementation of this function should return a value in the following range. [1, min(|session_remote_window_size|, |stream_remote_window_size|, |remote_max_frame_size|)]. If a value greater than this range is returned than the max allow value will be used. Returning a value smaller than this range is treated as ErrorCode.CALLBACK_FAILURE. The |frame_type| is provided for future extensibility and identifies the type of frame (see FrameType) for which to get the length for. Currently supported frame types are: HTTP2_DATA.

onDataChunk
bool onDataChunk(FrameFlags flags, int stream_id, ubyte[] data, bool pause)

Callback function invoked when a chunk of data in DATA frame is received. The |stream_id| is the stream this DATA frame belongs to. The |flags| is the flags of DATA frame which this data chunk is contained. `(flags & FrameFlags.END_STREAM) != 0` does not necessarily mean this chunk of data is the last one in the stream. You should use Connector.onFrame to determine that all data frames are received.

onFrame
bool onFrame(Frame frame)

Callback function invoked by Session.recv when a frame is received. The |user_data| pointer is the third argument passed in to the call to http2_session_client_new() or http2_session_server_new().

onFrameFailure
bool onFrameFailure(Frame frame, ErrorCode error_code)

Callback function invoked after the non-DATA frame |frame| is not sent because of the error. The error is indicated by the |error_code|, which is one of the values defined in ErrorCode.

onFrameHeader
bool onFrameHeader(FrameHeader hd)

Callback function invoked when a frame header is received. The |hd| points to received frame header.

onFrameReady
bool onFrameReady(Frame frame)

Callback function invoked just before the non-DATA frame |frame| is sent.

onFrameSent
bool onFrameSent(Frame frame)

Callback function invoked after the frame |frame| is sent.

onHeaderField
bool onHeaderField(Frame frame, HeaderField hf, bool pause, bool rst_stream)

Callback function invoked when a header header field is received for the |frame|. The |hf.name| of length |hf.name.length| is header name. The |hf.value| of length |hf.value.length| is header value. The |hf.flags| is a HeaderFlag.

onHeaders
bool onHeaders(Frame frame)

Callback function invoked when the reception of header block in HEADERS or PUSH_PROMISE is started. Each header header field will be emitted by Connector.onHeaderField`.

onInvalidFrame
bool onInvalidFrame(Frame frame, FrameError error_code, string reason)

Callback function invoked by Session.recv when an invalid non-DATA frame is received. The |error_code| indicates the error. It is usually one of the FrameError but that is not guaranteed. When this callback function is invoked, the library automatically submits either RST_STREAM or GOAWAY frame.

onStreamExit
bool onStreamExit(int stream_id, FrameError error_code)

Callback function invoked when the stream |stream_id| is closed. The reason of closure is indicated by the |error_code|. The |error_code| is usually one of FrameError, but that is not guaranteed.

read
int read(ubyte[] data)

Callback function invoked when Session wants to receive data from the remote peer. The implementation of this function must read at most |data.length| bytes of data and store it in |data|.

selectPaddingLength
int selectPaddingLength(Frame frame, int max_payloadlen)

Callback function invoked when the library asks application how many padding bytes are required for the transmission of the |frame|. The application must choose the total length of payload including padded bytes in range [frame.hd.length, max_payloadlen], inclusive. Choosing number not in this range will be treated as ErrorCode.CALLBACK_FAILURE. Returning `frame.hd.length` means no padding is added. Returning ErrorCode.CALLBACK_FAILURE will make Session.send() function immediately return ErrorCode.CALLBACK_FAILURE.

write
int write(ubyte[] data)

Callback function invoked when Session wants to send data to the remote peer. The implementation of this function must send at most |data.length| bytes of data stored in |data|. It must return the number of bytes sent if it succeeds. If it cannot send any single byte without blocking, it must return ErrorCode.WOULDBLOCK. For other errors, it must return ErrorCode.CALLBACK_FAILURE.

writeData
ErrorCode writeData(Frame frame, ubyte[] frame_hd, uint length)

Callback function invoked when DataFlags.NO_COPY is used in DataProvider to send complete DATA frame.

Meta