int nghttp2_session_recv(nghttp2_session *session)¶
Receives frames from the remote peer.
This function receives as many frames as possible until the user callback
nghttp2_error.NGHTTP2_ERR_WOULDBLOCK. This function calls several callback functions which are passed when initializing the session. Here is the simple time chart which tells when each callback is invoked:
nghttp2_recv_callbackis invoked one or more times to receive frame header.
When frame header is received,
If the frame is DATA frame:
If the frame is the control frame:
nghttp2_recv_callbackis invoked one or more times to receive whole frame.
If the received frame is valid, then following actions are taken. If the frame is either HEADERS or PUSH_PROMISE,
nghttp2_on_begin_headers_callbackis invoked. Then
nghttp2_on_header_callbackis invoked for each header name/value pair. For invalid header field,
nghttp2_on_invalid_header_callbackis called. After all name/value pairs are emitted successfully,
nghttp2_on_frame_recv_callbackis invoked. For other frames,
nghttp2_on_frame_recv_callbackis invoked. If the reception of the frame triggers the closure of the stream,
If the received frame is unpacked but is interpreted as invalid,
This function returns 0 if it succeeds, or one of the following negative error codes:
The remote peer did shutdown on the connection.
Out of memory.
The callback function failed.
Invalid client magic was detected. This error only returns when session was configured as server and
nghttp2_option_set_no_recv_client_magic()is not used with nonzero value.
Flooding was detected in this HTTP/2 session, and it must be closed. This is most likely caused by misbehaviour of peer.