Merge branch 'http2-debug-state-api'
This commit is contained in:
commit
0f8a5ffc23
|
@ -108,7 +108,11 @@ APIDOCS= \
|
|||
nghttp2_session_find_stream.rst \
|
||||
nghttp2_session_get_effective_local_window_size.rst \
|
||||
nghttp2_session_get_effective_recv_data_length.rst \
|
||||
nghttp2_session_get_hd_deflate_dynamic_table_size.rst \
|
||||
nghttp2_session_get_hd_inflate_dynamic_table_size.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 \
|
||||
nghttp2_session_get_remote_settings.rst \
|
||||
|
@ -117,6 +121,7 @@ APIDOCS= \
|
|||
nghttp2_session_get_stream_effective_local_window_size.rst \
|
||||
nghttp2_session_get_stream_effective_recv_data_length.rst \
|
||||
nghttp2_session_get_stream_local_close.rst \
|
||||
nghttp2_session_get_stream_local_window_size.rst \
|
||||
nghttp2_session_get_stream_remote_close.rst \
|
||||
nghttp2_session_get_stream_remote_window_size.rst \
|
||||
nghttp2_session_get_stream_user_data.rst \
|
||||
|
|
|
@ -3016,12 +3016,35 @@ nghttp2_session_get_stream_effective_recv_data_length(nghttp2_session *session,
|
|||
* `nghttp2_submit_window_update()`. This function takes into account
|
||||
* that and returns effective window size.
|
||||
*
|
||||
* This function does not take into account the amount of received
|
||||
* data from the remote endpoint. Use
|
||||
* `nghttp2_session_get_stream_local_window_size()` to know the amount
|
||||
* of data the remote endpoint can send without receiving stream level
|
||||
* WINDOW_UPDATE frame. Note that each stream is still subject to the
|
||||
* connection level flow control.
|
||||
*
|
||||
* This function returns -1 if it fails.
|
||||
*/
|
||||
NGHTTP2_EXTERN int32_t
|
||||
nghttp2_session_get_stream_effective_local_window_size(nghttp2_session *session,
|
||||
int32_t stream_id);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* Returns the amount of flow-controlled payload (e.g., DATA) that the
|
||||
* remote endpoint can send without receiving stream level
|
||||
* WINDOW_UPDATE frame. It is also subject to the connection level
|
||||
* flow control. So the actual amount of data to send is
|
||||
* min(`nghttp2_session_get_stream_local_window_size()`,
|
||||
* `nghttp2_session_get_local_window_size()`).
|
||||
*
|
||||
* This function returns -1 if it fails.
|
||||
*/
|
||||
NGHTTP2_EXTERN int32_t
|
||||
nghttp2_session_get_stream_local_window_size(nghttp2_session *session,
|
||||
int32_t stream_id);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
|
@ -3047,11 +3070,32 @@ nghttp2_session_get_effective_recv_data_length(nghttp2_session *session);
|
|||
* `nghttp2_submit_window_update()`. This function takes into account
|
||||
* that and returns effective window size.
|
||||
*
|
||||
* This function does not take into account the amount of received
|
||||
* data from the remote endpoint. Use
|
||||
* `nghttp2_session_get_local_window_size()` to know the amount of
|
||||
* data the remote endpoint can send without receiving
|
||||
* connection-level WINDOW_UPDATE frame. Note that each stream is
|
||||
* still subject to the stream level flow control.
|
||||
*
|
||||
* This function returns -1 if it fails.
|
||||
*/
|
||||
NGHTTP2_EXTERN int32_t
|
||||
nghttp2_session_get_effective_local_window_size(nghttp2_session *session);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* Returns the amount of flow-controlled payload (e.g., DATA) that the
|
||||
* remote endpoint can send without receiving connection level
|
||||
* WINDOW_UPDATE frame. Note that each stream is still subject to the
|
||||
* stream level flow control (see
|
||||
* `nghttp2_session_get_stream_local_window_size()`).
|
||||
*
|
||||
* This function returns -1 if it fails.
|
||||
*/
|
||||
NGHTTP2_EXTERN int32_t
|
||||
nghttp2_session_get_local_window_size(nghttp2_session *session);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
|
@ -3100,6 +3144,24 @@ NGHTTP2_EXTERN int
|
|||
nghttp2_session_get_stream_remote_close(nghttp2_session *session,
|
||||
int32_t stream_id);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* Returns the current dynamic table size of HPACK inflater, including
|
||||
* the overhead 32 bytes per entry described in RFC 7541.
|
||||
*/
|
||||
NGHTTP2_EXTERN size_t
|
||||
nghttp2_session_get_hd_inflate_dynamic_table_size(nghttp2_session *session);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* Returns the current dynamic table size of HPACK deflater including
|
||||
* the overhead 32 bytes per entry described in RFC 7541.
|
||||
*/
|
||||
NGHTTP2_EXTERN size_t
|
||||
nghttp2_session_get_hd_deflate_dynamic_table_size(nghttp2_session *session);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
|
@ -3207,6 +3269,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
|
||||
*
|
||||
|
|
|
@ -7172,6 +7172,26 @@ nghttp2_session_get_stream_effective_local_window_size(nghttp2_session *session,
|
|||
return stream->local_window_size;
|
||||
}
|
||||
|
||||
int32_t nghttp2_session_get_stream_local_window_size(nghttp2_session *session,
|
||||
int32_t stream_id) {
|
||||
nghttp2_stream *stream;
|
||||
int32_t size;
|
||||
stream = nghttp2_session_get_stream(session, stream_id);
|
||||
if (stream == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
size = stream->local_window_size - stream->recv_window_size;
|
||||
|
||||
/* size could be negative if local endpoint reduced
|
||||
SETTINGS_INITIAL_WINDOW_SIZE */
|
||||
if (size < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
int32_t
|
||||
nghttp2_session_get_effective_recv_data_length(nghttp2_session *session) {
|
||||
return session->recv_window_size < 0 ? 0 : session->recv_window_size;
|
||||
|
@ -7182,6 +7202,10 @@ nghttp2_session_get_effective_local_window_size(nghttp2_session *session) {
|
|||
return session->local_window_size;
|
||||
}
|
||||
|
||||
int32_t nghttp2_session_get_local_window_size(nghttp2_session *session) {
|
||||
return session->local_window_size - session->recv_window_size;
|
||||
}
|
||||
|
||||
int32_t nghttp2_session_get_stream_remote_window_size(nghttp2_session *session,
|
||||
int32_t stream_id) {
|
||||
nghttp2_stream *stream;
|
||||
|
@ -7220,6 +7244,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,
|
||||
|
@ -7551,3 +7595,13 @@ int nghttp2_session_create_idle_stream(nghttp2_session *session,
|
|||
called. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t
|
||||
nghttp2_session_get_hd_inflate_dynamic_table_size(nghttp2_session *session) {
|
||||
return nghttp2_hd_inflate_get_dynamic_table_size(&session->hd_inflater);
|
||||
}
|
||||
|
||||
size_t
|
||||
nghttp2_session_get_hd_deflate_dynamic_table_size(nghttp2_session *session) {
|
||||
return nghttp2_hd_deflate_get_dynamic_table_size(&session->hd_deflater);
|
||||
}
|
||||
|
|
|
@ -5113,6 +5113,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);
|
||||
|
@ -5121,6 +5130,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);
|
||||
|
||||
|
@ -5135,6 +5150,7 @@ void test_nghttp2_submit_settings_update_local_window_size(void) {
|
|||
nghttp2_stream *stream;
|
||||
nghttp2_frame ack_frame;
|
||||
nghttp2_mem *mem;
|
||||
nghttp2_option *option;
|
||||
|
||||
mem = nghttp2_mem_default();
|
||||
nghttp2_frame_settings_init(&ack_frame.settings, NGHTTP2_FLAG_ACK, NULL, 0);
|
||||
|
@ -5170,6 +5186,32 @@ void test_nghttp2_submit_settings_update_local_window_size(void) {
|
|||
|
||||
nghttp2_session_del(session);
|
||||
|
||||
/* Without auto-window update */
|
||||
nghttp2_option_new(&option);
|
||||
nghttp2_option_set_no_auto_window_update(option, 1);
|
||||
|
||||
nghttp2_session_server_new2(&session, &callbacks, NULL, option);
|
||||
|
||||
nghttp2_option_del(option);
|
||||
|
||||
stream = open_recv_stream(session, 1);
|
||||
stream->local_window_size = NGHTTP2_INITIAL_WINDOW_SIZE + 100;
|
||||
stream->recv_window_size = 32768;
|
||||
|
||||
CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 1));
|
||||
CU_ASSERT(0 == nghttp2_session_send(session));
|
||||
CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &ack_frame, 0));
|
||||
|
||||
stream = nghttp2_session_get_stream(session, 1);
|
||||
|
||||
CU_ASSERT(32768 == stream->recv_window_size);
|
||||
CU_ASSERT(16 * 1024 + 100 == stream->local_window_size);
|
||||
/* Check that we can handle the case where local_window_size <
|
||||
recv_window_size */
|
||||
CU_ASSERT(0 == nghttp2_session_get_stream_local_window_size(session, 1));
|
||||
|
||||
nghttp2_session_del(session);
|
||||
|
||||
/* Check overflow case */
|
||||
iv[0].value = 128 * 1024;
|
||||
nghttp2_session_server_new(&session, &callbacks, NULL);
|
||||
|
@ -6557,19 +6599,34 @@ void test_nghttp2_session_get_effective_local_window_size(void) {
|
|||
|
||||
CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1000 ==
|
||||
nghttp2_session_get_effective_local_window_size(session));
|
||||
CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1000 ==
|
||||
nghttp2_session_get_local_window_size(session));
|
||||
CU_ASSERT(0 == nghttp2_session_get_effective_recv_data_length(session));
|
||||
|
||||
nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, -50);
|
||||
/* Now session->recv_window_size = -50 */
|
||||
CU_ASSERT(-50 == session->recv_window_size);
|
||||
CU_ASSERT(50 == session->recv_reduction);
|
||||
CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 950 ==
|
||||
nghttp2_session_get_effective_local_window_size(session));
|
||||
CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1000 ==
|
||||
nghttp2_session_get_local_window_size(session));
|
||||
CU_ASSERT(0 == nghttp2_session_get_effective_recv_data_length(session));
|
||||
|
||||
session->recv_window_size += 50;
|
||||
|
||||
/* Now session->recv_window_size = 0 */
|
||||
|
||||
CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 950 ==
|
||||
nghttp2_session_get_local_window_size(session));
|
||||
|
||||
nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, 100);
|
||||
CU_ASSERT(50 == session->recv_window_size);
|
||||
CU_ASSERT(0 == session->recv_reduction);
|
||||
CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1050 ==
|
||||
nghttp2_session_get_effective_local_window_size(session));
|
||||
CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1000 ==
|
||||
nghttp2_session_get_local_window_size(session));
|
||||
CU_ASSERT(50 == nghttp2_session_get_effective_recv_data_length(session));
|
||||
|
||||
/* Check stream flow control */
|
||||
|
@ -6578,6 +6635,8 @@ void test_nghttp2_session_get_effective_local_window_size(void) {
|
|||
|
||||
CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 1000 ==
|
||||
nghttp2_session_get_stream_effective_local_window_size(session, 1));
|
||||
CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 1000 ==
|
||||
nghttp2_session_get_stream_local_window_size(session, 1));
|
||||
CU_ASSERT(0 ==
|
||||
nghttp2_session_get_stream_effective_recv_data_length(session, 1));
|
||||
|
||||
|
@ -6585,6 +6644,8 @@ void test_nghttp2_session_get_effective_local_window_size(void) {
|
|||
/* Now stream->recv_window_size = -50 */
|
||||
CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 950 ==
|
||||
nghttp2_session_get_stream_effective_local_window_size(session, 1));
|
||||
CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 1000 ==
|
||||
nghttp2_session_get_stream_local_window_size(session, 1));
|
||||
CU_ASSERT(0 ==
|
||||
nghttp2_session_get_stream_effective_recv_data_length(session, 1));
|
||||
|
||||
|
@ -6593,6 +6654,8 @@ void test_nghttp2_session_get_effective_local_window_size(void) {
|
|||
nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 1, 100);
|
||||
CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 1050 ==
|
||||
nghttp2_session_get_stream_effective_local_window_size(session, 1));
|
||||
CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 1000 ==
|
||||
nghttp2_session_get_stream_local_window_size(session, 1));
|
||||
CU_ASSERT(50 ==
|
||||
nghttp2_session_get_stream_effective_recv_data_length(session, 1));
|
||||
|
||||
|
@ -9587,7 +9650,11 @@ void test_nghttp2_session_set_local_window_size(void) {
|
|||
CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1 ==
|
||||
stream->local_window_size);
|
||||
CU_ASSERT(4096 == stream->recv_window_size);
|
||||
CU_ASSERT(65536 - 4096 ==
|
||||
nghttp2_session_get_stream_local_window_size(session, 1));
|
||||
|
||||
item = nghttp2_session_get_next_ob_item(session);
|
||||
|
||||
CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type);
|
||||
CU_ASSERT(1 == item->frame.window_update.hd.stream_id);
|
||||
CU_ASSERT(1 == item->frame.window_update.window_size_increment);
|
||||
|
@ -9600,7 +9667,11 @@ void test_nghttp2_session_set_local_window_size(void) {
|
|||
CU_ASSERT(32768 == stream->local_window_size);
|
||||
CU_ASSERT(-28672 == stream->recv_window_size);
|
||||
CU_ASSERT(32768 == stream->recv_reduction);
|
||||
CU_ASSERT(65536 - 4096 ==
|
||||
nghttp2_session_get_stream_local_window_size(session, 1));
|
||||
|
||||
item = nghttp2_session_get_next_ob_item(session);
|
||||
|
||||
CU_ASSERT(item == NULL);
|
||||
|
||||
/* Increase local window size */
|
||||
|
@ -9609,6 +9680,8 @@ void test_nghttp2_session_set_local_window_size(void) {
|
|||
CU_ASSERT(49152 == stream->local_window_size);
|
||||
CU_ASSERT(-12288 == stream->recv_window_size);
|
||||
CU_ASSERT(16384 == stream->recv_reduction);
|
||||
CU_ASSERT(65536 - 4096 ==
|
||||
nghttp2_session_get_stream_local_window_size(session, 1));
|
||||
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
|
||||
|
||||
/* Increase local window again */
|
||||
|
@ -9617,7 +9690,11 @@ void test_nghttp2_session_set_local_window_size(void) {
|
|||
CU_ASSERT(65537 == stream->local_window_size);
|
||||
CU_ASSERT(4096 == stream->recv_window_size);
|
||||
CU_ASSERT(0 == stream->recv_reduction);
|
||||
CU_ASSERT(65537 - 4096 ==
|
||||
nghttp2_session_get_stream_local_window_size(session, 1));
|
||||
|
||||
item = nghttp2_session_get_next_ob_item(session);
|
||||
|
||||
CU_ASSERT(1 == item->frame.window_update.window_size_increment);
|
||||
|
||||
CU_ASSERT(0 == nghttp2_session_send(session));
|
||||
|
@ -9629,7 +9706,10 @@ void test_nghttp2_session_set_local_window_size(void) {
|
|||
CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1 ==
|
||||
session->local_window_size);
|
||||
CU_ASSERT(4096 == session->recv_window_size);
|
||||
CU_ASSERT(65536 - 4096 == nghttp2_session_get_local_window_size(session));
|
||||
|
||||
item = nghttp2_session_get_next_ob_item(session);
|
||||
|
||||
CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type);
|
||||
CU_ASSERT(0 == item->frame.window_update.hd.stream_id);
|
||||
CU_ASSERT(1 == item->frame.window_update.window_size_increment);
|
||||
|
@ -9642,7 +9722,10 @@ void test_nghttp2_session_set_local_window_size(void) {
|
|||
CU_ASSERT(32768 == session->local_window_size);
|
||||
CU_ASSERT(-28672 == session->recv_window_size);
|
||||
CU_ASSERT(32768 == session->recv_reduction);
|
||||
CU_ASSERT(65536 - 4096 == nghttp2_session_get_local_window_size(session));
|
||||
|
||||
item = nghttp2_session_get_next_ob_item(session);
|
||||
|
||||
CU_ASSERT(item == NULL);
|
||||
|
||||
/* Increase local window size */
|
||||
|
@ -9651,6 +9734,7 @@ void test_nghttp2_session_set_local_window_size(void) {
|
|||
CU_ASSERT(49152 == session->local_window_size);
|
||||
CU_ASSERT(-12288 == session->recv_window_size);
|
||||
CU_ASSERT(16384 == session->recv_reduction);
|
||||
CU_ASSERT(65536 - 4096 == nghttp2_session_get_local_window_size(session));
|
||||
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
|
||||
|
||||
/* Increase local window again */
|
||||
|
@ -9659,7 +9743,10 @@ void test_nghttp2_session_set_local_window_size(void) {
|
|||
CU_ASSERT(65537 == session->local_window_size);
|
||||
CU_ASSERT(4096 == session->recv_window_size);
|
||||
CU_ASSERT(0 == session->recv_reduction);
|
||||
CU_ASSERT(65537 - 4096 == nghttp2_session_get_local_window_size(session));
|
||||
|
||||
item = nghttp2_session_get_next_ob_item(session);
|
||||
|
||||
CU_ASSERT(1 == item->frame.window_update.window_size_increment);
|
||||
|
||||
CU_ASSERT(0 == nghttp2_session_send(session));
|
||||
|
|
Loading…
Reference in New Issue