Add nghttp2_session_get_local_settings() API function

This commit is contained in:
Tatsuhiro Tsujikawa 2016-08-21 19:33:01 +09:00
parent 759f6c0b39
commit e693f75670
4 changed files with 47 additions and 0 deletions

View File

@ -108,6 +108,7 @@ APIDOCS= \
nghttp2_session_get_effective_local_window_size.rst \
nghttp2_session_get_effective_recv_data_length.rst \
nghttp2_session_get_last_proc_stream_id.rst \
nghttp2_session_get_local_settings.rst \
nghttp2_session_get_local_window_size.rst \
nghttp2_session_get_next_stream_id.rst \
nghttp2_session_get_outbound_queue_size.rst \

View File

@ -3242,6 +3242,17 @@ NGHTTP2_EXTERN uint32_t
nghttp2_session_get_remote_settings(nghttp2_session *session,
nghttp2_settings_id id);
/**
* @function
*
* Returns the value of SETTINGS |id| of local endpoint acknowledged
* by the remote endpoint. The |id| must be one of the values defined
* in :enum:`nghttp2_settings_id`.
*/
NGHTTP2_EXTERN uint32_t
nghttp2_session_get_local_settings(nghttp2_session *session,
nghttp2_settings_id id);
/**
* @function
*

View File

@ -7237,6 +7237,26 @@ uint32_t nghttp2_session_get_remote_settings(nghttp2_session *session,
assert(0);
}
uint32_t nghttp2_session_get_local_settings(nghttp2_session *session,
nghttp2_settings_id id) {
switch (id) {
case NGHTTP2_SETTINGS_HEADER_TABLE_SIZE:
return session->local_settings.header_table_size;
case NGHTTP2_SETTINGS_ENABLE_PUSH:
return session->local_settings.enable_push;
case NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS:
return session->local_settings.max_concurrent_streams;
case NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE:
return session->local_settings.initial_window_size;
case NGHTTP2_SETTINGS_MAX_FRAME_SIZE:
return session->local_settings.max_frame_size;
case NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
return session->local_settings.max_header_list_size;
}
assert(0);
}
static int nghttp2_session_upgrade_internal(nghttp2_session *session,
const uint8_t *settings_payload,
size_t settings_payloadlen,

View File

@ -5112,6 +5112,15 @@ void test_nghttp2_submit_settings(void) {
CU_ASSERT(50 == session->pending_local_max_concurrent_stream);
/* before receiving SETTINGS ACK, local settings have still default
values */
CU_ASSERT(NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS ==
nghttp2_session_get_local_settings(
session, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS));
CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE ==
nghttp2_session_get_local_settings(
session, NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE));
nghttp2_frame_settings_init(&ack_frame.settings, NGHTTP2_FLAG_ACK, NULL, 0);
CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &ack_frame, 0));
nghttp2_frame_settings_free(&ack_frame.settings, mem);
@ -5120,6 +5129,12 @@ void test_nghttp2_submit_settings(void) {
CU_ASSERT(1023 == session->hd_inflater.ctx.hd_table_bufsize_max);
CU_ASSERT(111 == session->hd_inflater.min_hd_table_bufsize_max);
CU_ASSERT(50 == session->local_settings.max_concurrent_streams);
CU_ASSERT(50 == nghttp2_session_get_local_settings(
session, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS));
CU_ASSERT(16 * 1024 == nghttp2_session_get_local_settings(
session, NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE));
/* We just keep the last seen value */
CU_ASSERT(50 == session->pending_local_max_concurrent_stream);