Commit 794633f8 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Add nghttp2_session_set_stream_user_data API function

parent e04e6ccd
...@@ -1577,17 +1577,36 @@ int nghttp2_session_want_write(nghttp2_session *session); ...@@ -1577,17 +1577,36 @@ int nghttp2_session_want_write(nghttp2_session *session);
* @function * @function
* *
* Returns stream_user_data for the stream |stream_id|. The * Returns stream_user_data for the stream |stream_id|. The
* stream_user_data is provided by `nghttp2_submit_request()` or * stream_user_data is provided by `nghttp2_submit_request()`,
* `nghttp2_submit_headers()`. If the stream is initiated by the * `nghttp2_submit_headers()` or
* remote endpoint, stream_user_data is always ``NULL``. If the stream * `nghttp2_session_set_stream_user_data()`. Unless it is set using
* is initiated by the local endpoint and ``NULL`` is given in * `nghttp2_session_set_stream_user_data()`, if the stream is
* `nghttp2_submit_request()` or `nghttp2_submit_headers()`, then * initiated by the remote endpoint, stream_user_data is always
* this function returns ``NULL``. If the stream does not exist, this * ``NULL``. If the stream does not exist, this function returns
* function returns ``NULL``. * ``NULL``.
*/ */
void* nghttp2_session_get_stream_user_data(nghttp2_session *session, void* nghttp2_session_get_stream_user_data(nghttp2_session *session,
int32_t stream_id); int32_t stream_id);
/**
* @function
*
* Sets the |stream_user_data| to the stream denoted by the
* |stream_id|. If a stream user data is already set to the stream, it
* is replaced with the |stream_user_data|. It is valid to specify
* ``NULL`` in the |stream_user_data|, which nullifies the associated
* data pointer.
*
* This function returns 0 if it succeeds, or one of following
* negative error codes:
*
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
* The stream does not exist
*/
int nghttp2_session_set_stream_user_data(nghttp2_session *session,
int32_t stream_id,
void *stream_user_data);
/** /**
* @function * @function
* *
......
...@@ -3622,6 +3622,19 @@ void* nghttp2_session_get_stream_user_data(nghttp2_session *session, ...@@ -3622,6 +3622,19 @@ void* nghttp2_session_get_stream_user_data(nghttp2_session *session,
} }
} }
int nghttp2_session_set_stream_user_data(nghttp2_session *session,
int32_t stream_id,
void *stream_user_data)
{
nghttp2_stream *stream;
stream = nghttp2_session_get_stream(session, stream_id);
if(!stream) {
return NGHTTP2_ERR_INVALID_ARGUMENT;
}
stream->stream_user_data = stream_user_data;
return 0;
}
int nghttp2_session_resume_data(nghttp2_session *session, int32_t stream_id) int nghttp2_session_resume_data(nghttp2_session *session, int32_t stream_id)
{ {
int r; int r;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment