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`
|
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
|
||||||
* The |settings_payload| is badly formed.
|
* The |settings_payload| is badly formed.
|
||||||
* :enum:`NGHTTP2_ERR_PROTO`
|
* :enum:`NGHTTP2_ERR_PROTO`
|
||||||
* The stream ID 1 is already used or closed; or is not available;
|
* 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`.
|
|
||||||
*/
|
*/
|
||||||
int nghttp2_session_upgrade(nghttp2_session *session,
|
int nghttp2_session_upgrade(nghttp2_session *session,
|
||||||
const uint8_t *settings_payload,
|
const uint8_t *settings_payload,
|
||||||
|
|
|
@ -5568,9 +5568,6 @@ int nghttp2_session_upgrade(nghttp2_session *session,
|
||||||
nghttp2_settings_entry *iv;
|
nghttp2_settings_entry *iv;
|
||||||
size_t niv;
|
size_t niv;
|
||||||
int rv;
|
int rv;
|
||||||
int max_conn_val_seen = 0;
|
|
||||||
int ini_win_size_seen = 0;
|
|
||||||
size_t i;
|
|
||||||
nghttp2_priority_spec pri_spec;
|
nghttp2_priority_spec pri_spec;
|
||||||
|
|
||||||
if((!session->server && session->next_stream_id != 1) ||
|
if((!session->server && session->next_stream_id != 1) ||
|
||||||
|
@ -5585,17 +5582,7 @@ int nghttp2_session_upgrade(nghttp2_session *session,
|
||||||
if(rv != 0) {
|
if(rv != 0) {
|
||||||
return rv;
|
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) {
|
if(session->server) {
|
||||||
memset(&frame.hd, 0, sizeof(frame.hd));
|
memset(&frame.hd, 0, sizeof(frame.hd));
|
||||||
frame.settings.iv = iv;
|
frame.settings.iv = iv;
|
||||||
|
|
|
@ -2578,28 +2578,13 @@ void test_nghttp2_session_upgrade(void)
|
||||||
&callbacks));
|
&callbacks));
|
||||||
nghttp2_session_del(session);
|
nghttp2_session_del(session);
|
||||||
|
|
||||||
/* Check required settings */
|
/* Empty SETTINGS is OK */
|
||||||
iv[0].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS;
|
|
||||||
iv[0].value = 1;
|
|
||||||
settings_payloadlen = nghttp2_pack_settings_payload(settings_payload,
|
settings_payloadlen = nghttp2_pack_settings_payload(settings_payload,
|
||||||
sizeof(settings_payload),
|
sizeof(settings_payload),
|
||||||
iv, 1);
|
NULL, 0);
|
||||||
|
|
||||||
nghttp2_session_client_new(&session, &callbacks, NULL);
|
nghttp2_session_client_new(&session, &callbacks, NULL);
|
||||||
CU_ASSERT(NGHTTP2_ERR_PROTO ==
|
CU_ASSERT(0 == nghttp2_session_upgrade(session, settings_payload,
|
||||||
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));
|
settings_payloadlen, NULL));
|
||||||
nghttp2_session_del(session);
|
nghttp2_session_del(session);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue