Allow empty SETTINGS in upgrade
This commit is contained in:
parent
2a49e164c8
commit
1e38ceb1cd
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -2578,28 +2578,13 @@ 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,
|
||||
CU_ASSERT(0 == nghttp2_session_upgrade(session, settings_payload,
|
||||
settings_payloadlen, NULL));
|
||||
nghttp2_session_del(session);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue