Merge pull request #1742 from nghttp2/ignore-priority-in-pp

Do not parse priority header field value included in PUSH_PROMISE
This commit is contained in:
Tatsuhiro Tsujikawa 2022-06-23 23:09:21 +09:00 committed by GitHub
commit b5c4ba8322
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 1 deletions

View File

@ -217,6 +217,8 @@ static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
break;
case NGHTTP2_TOKEN_PRIORITY:
if (!trailer &&
/* Do not parse the header field in PUSH_PROMISE. */
(stream->stream_id & 1) &&
(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) &&
!(stream->http_flags & NGHTTP2_HTTP_FLAG_BAD_PRIORITY)) {
nghttp2_extpri_from_uint8(&extpri, stream->http_extpri);

View File

@ -1885,9 +1885,49 @@ void test_nghttp2_session_recv_headers_with_extpri(void) {
CU_ASSERT(2 == nghttp2_extpri_uint8_urgency(stream->extpri));
CU_ASSERT(1 == nghttp2_extpri_uint8_inc(stream->extpri));
nghttp2_bufs_free(&bufs);
nghttp2_hd_deflate_free(&deflater);
nghttp2_session_del(session);
nghttp2_bufs_reset(&bufs);
/* Client should ignore priority header field included in
PUSH_PROMISE. */
nghttp2_session_client_new(&session, &callbacks, NULL);
nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, &iv, 1);
open_sent_stream(session, 1);
nghttp2_hd_deflate_init(&deflater, mem);
nvlen = ARRLEN(extpri_reqnv);
nghttp2_nv_array_copy(&nva, extpri_reqnv, nvlen, mem);
nghttp2_frame_push_promise_init(&frame.push_promise, NGHTTP2_FLAG_END_HEADERS,
1, 2, nva, nvlen);
rv = nghttp2_frame_pack_push_promise(&bufs, &frame.push_promise, &deflater);
CU_ASSERT(0 == rv);
CU_ASSERT(nghttp2_bufs_len(&bufs) > 0);
nghttp2_frame_push_promise_free(&frame.push_promise, mem);
buf = &bufs.head->buf;
assert(nghttp2_bufs_len(&bufs) == nghttp2_buf_len(buf));
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf));
stream = nghttp2_session_get_stream(session, 2);
CU_ASSERT(NGHTTP2_EXTPRI_DEFAULT_URGENCY ==
nghttp2_extpri_uint8_urgency(stream->http_extpri));
CU_ASSERT(NGHTTP2_EXTPRI_DEFAULT_URGENCY ==
nghttp2_extpri_uint8_urgency(stream->extpri));
nghttp2_hd_deflate_free(&deflater);
nghttp2_session_del(session);
nghttp2_bufs_free(&bufs);
}
void test_nghttp2_session_server_recv_push_response(void) {