From 1e38ceb1cd9152eacece8b398911af475e5b4880 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 4 Apr 2014 20:23:46 +0900 Subject: [PATCH] Allow empty SETTINGS in upgrade --- lib/includes/nghttp2/nghttp2.h | 5 +---- lib/nghttp2_session.c | 15 +-------------- tests/nghttp2_session_test.c | 23 ++++------------------- 3 files changed, 6 insertions(+), 37 deletions(-) diff --git a/lib/includes/nghttp2/nghttp2.h b/lib/includes/nghttp2/nghttp2.h index a53e334b..5f59f7cf 100644 --- a/lib/includes/nghttp2/nghttp2.h +++ b/lib/includes/nghttp2/nghttp2.h @@ -2061,10 +2061,7 @@ int nghttp2_session_terminate_session(nghttp2_session *session, * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` * The |settings_payload| is badly formed. * :enum:`NGHTTP2_ERR_PROTO` - * The stream ID 1 is already used or closed; or is not available; - * or the |settings_payload| does not include both - * :enum:`NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS` and - * :enum:`NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE`. + * The stream ID 1 is already used or closed; or is not available. */ int nghttp2_session_upgrade(nghttp2_session *session, const uint8_t *settings_payload, diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index b420c983..cb699dd4 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -5568,9 +5568,6 @@ int nghttp2_session_upgrade(nghttp2_session *session, nghttp2_settings_entry *iv; size_t niv; int rv; - int max_conn_val_seen = 0; - int ini_win_size_seen = 0; - size_t i; nghttp2_priority_spec pri_spec; if((!session->server && session->next_stream_id != 1) || @@ -5585,17 +5582,7 @@ int nghttp2_session_upgrade(nghttp2_session *session, if(rv != 0) { return rv; } - for(i = 0; i < niv; ++i) { - if(iv[i].settings_id == NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS) { - max_conn_val_seen = 1; - } else if(iv[i].settings_id == NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE) { - ini_win_size_seen = 1; - } - } - if(!max_conn_val_seen || !ini_win_size_seen) { - free(iv); - return NGHTTP2_ERR_PROTO; - } + if(session->server) { memset(&frame.hd, 0, sizeof(frame.hd)); frame.settings.iv = iv; diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 0fc461d3..aece67ec 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -2578,29 +2578,14 @@ void test_nghttp2_session_upgrade(void) &callbacks)); nghttp2_session_del(session); - /* Check required settings */ - iv[0].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS; - iv[0].value = 1; + /* Empty SETTINGS is OK */ settings_payloadlen = nghttp2_pack_settings_payload(settings_payload, sizeof(settings_payload), - iv, 1); + NULL, 0); nghttp2_session_client_new(&session, &callbacks, NULL); - CU_ASSERT(NGHTTP2_ERR_PROTO == - nghttp2_session_upgrade(session, settings_payload, - settings_payloadlen, NULL)); - nghttp2_session_del(session); - - iv[0].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; - iv[0].value = 4095; - settings_payloadlen = nghttp2_pack_settings_payload(settings_payload, - sizeof(settings_payload), - iv, 1); - - nghttp2_session_client_new(&session, &callbacks, NULL); - CU_ASSERT(NGHTTP2_ERR_PROTO == - nghttp2_session_upgrade(session, settings_payload, - settings_payloadlen, NULL)); + CU_ASSERT(0 == nghttp2_session_upgrade(session, settings_payload, + settings_payloadlen, NULL)); nghttp2_session_del(session); }