[][src]Type Definition libnghttp2_sys::nghttp2_on_frame_recv_callback

type nghttp2_on_frame_recv_callback = Option<unsafe extern "C" fn(session: *mut nghttp2_session, frame: *const nghttp2_frame, user_data: *mut c_void) -> c_int>;

@functypedef

Callback function invoked by nghttp2_session_recv() and nghttp2_session_mem_recv() when a frame is received. The |user_data| pointer is the third argument passed in to the call to nghttp2_session_client_new() or nghttp2_session_server_new().

If frame is HEADERS or PUSH_PROMISE, the nva and nvlen member of their data structure are always NULL and 0 respectively. The header name/value pairs are emitted via :type:nghttp2_on_header_callback.

For HEADERS, PUSH_PROMISE and DATA frames, this callback may be called after stream is closed (see :type:nghttp2_on_stream_close_callback). The application should check that stream is still alive using its own stream management or :func:nghttp2_session_get_stream_user_data().

Only HEADERS and DATA frame can signal the end of incoming data. If frame->hd.flags & NGHTTP2_FLAG_END_STREAM is nonzero, the |frame| is the last frame from the remote peer in this stream.

This callback won't be called for CONTINUATION frames. HEADERS/PUSH_PROMISE + CONTINUATIONs are treated as single frame.

The implementation of this function must return 0 if it succeeds. If nonzero value is returned, it is treated as fatal error and nghttp2_session_recv() and nghttp2_session_mem_recv() functions immediately return :enum:NGHTTP2_ERR_CALLBACK_FAILURE.

To set this callback to :type:nghttp2_session_callbacks, use nghttp2_session_callbacks_set_on_frame_recv_callback().