Add nghttp2_session_{set,get}_next_stream_id API function

This commit is contained in:
Tatsuhiro Tsujikawa 2014-12-13 01:18:15 +09:00
parent 280c9dfcf3
commit ee158fb0aa
2 changed files with 41 additions and 0 deletions

View File

@ -2435,6 +2435,32 @@ int nghttp2_session_terminate_session2(nghttp2_session *session,
uint32_t nghttp2_session_get_remote_settings(nghttp2_session *session, uint32_t nghttp2_session_get_remote_settings(nghttp2_session *session,
nghttp2_settings_id id); nghttp2_settings_id id);
/**
* @function
*
* Tells the |session| that next stream ID is |next_stream_id|. The
* |next_stream_id| must be equal or greater than the value returned
* by `nghttp2_session_get_next_stream_id()`.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
* The |next_stream_id| is strictly less than the value
* `nghttp2_session_get_next_stream_id()` returns.
*/
int nghttp2_session_set_next_stream_id(nghttp2_session *session,
int32_t next_stream_id);
/**
* @function
*
* Returns the next outgoing stream ID. Notice that return type is
* uint32_t. If we run out of stream ID for this session, this
* function returns 1 << 31.
*/
uint32_t nghttp2_session_get_next_stream_id(nghttp2_session *session);
/** /**
* @function * @function
* *

View File

@ -6158,3 +6158,18 @@ int nghttp2_session_consume(nghttp2_session *session, int32_t stream_id,
return 0; return 0;
} }
int nghttp2_session_set_next_stream_id(nghttp2_session *session,
int32_t next_stream_id) {
if (next_stream_id < 0 ||
session->next_stream_id > (uint32_t)next_stream_id) {
return NGHTTP2_ERR_INVALID_ARGUMENT;
}
session->next_stream_id = next_stream_id;
return 0;
}
uint32_t nghttp2_session_get_next_stream_id(nghttp2_session *session) {
return session->next_stream_id;
}