Connection error if header continuation is used by peer for now

This commit is contained in:
Tatsuhiro Tsujikawa 2013-08-28 23:38:56 +09:00
parent 5c6ef84b97
commit 66e5ac03a6
2 changed files with 18 additions and 4 deletions

View File

@ -395,6 +395,10 @@ int nghttp2_frame_unpack_headers_without_nv(nghttp2_headers *frame,
size_t payloadlen)
{
nghttp2_frame_unpack_frame_hd(&frame->hd, head);
/* TODO Return error if header continuation is used for now */
if((head[3] & NGHTTP2_FLAG_END_HEADERS) == 0) {
return NGHTTP2_ERR_PROTO;
}
if(head[3] & NGHTTP2_FLAG_PRIORITY) {
if(payloadlen < 4) {
return NGHTTP2_ERR_INVALID_FRAME;
@ -583,6 +587,10 @@ int nghttp2_frame_unpack_push_promise_without_nv(nghttp2_push_promise *frame,
size_t payloadlen)
{
nghttp2_frame_unpack_frame_hd(&frame->hd, head);
/* TODO Return error if header continuation is used for now */
if((head[3] & NGHTTP2_FLAG_END_PUSH_PROMISE) == 0) {
return NGHTTP2_ERR_PROTO;
}
if(payloadlen < 4) {
return NGHTTP2_ERR_INVALID_FRAME;
}

View File

@ -116,7 +116,9 @@ void test_nghttp2_frame_pack_headers()
nghttp2_hd_inflate_init(&inflater, NGHTTP2_HD_SIDE_SERVER);
nvlen = nghttp2_nv_array_from_cstr(&nva, headers);
nghttp2_frame_headers_init(&frame, NGHTTP2_FLAG_END_STREAM, 1000000007,
nghttp2_frame_headers_init(&frame,
NGHTTP2_FLAG_END_STREAM|NGHTTP2_FLAG_END_HEADERS,
1000000007,
1 << 20, nva, nvlen);
framelen = nghttp2_frame_pack_headers(&buf, &buflen, &frame, &deflater);
nghttp2_hd_end_headers(&deflater);
@ -126,7 +128,8 @@ void test_nghttp2_frame_pack_headers()
&inflater,
buf, framelen));
check_frame_header(framelen - NGHTTP2_FRAME_HEAD_LENGTH, NGHTTP2_HEADERS,
NGHTTP2_FLAG_END_STREAM, 1000000007, &oframe.hd);
NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS,
1000000007, &oframe.hd);
/* We didn't include PRIORITY flag so priority is not packed */
CU_ASSERT(1 << 30 == oframe.pri);
CU_ASSERT(7 == oframe.nvlen);
@ -147,7 +150,8 @@ void test_nghttp2_frame_pack_headers()
&inflater,
buf, framelen));
check_frame_header(framelen - NGHTTP2_FRAME_HEAD_LENGTH, NGHTTP2_HEADERS,
NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_PRIORITY,
NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS |
NGHTTP2_FLAG_PRIORITY,
1000000007, &oframe.hd);
CU_ASSERT(1 << 20 == oframe.pri);
CU_ASSERT(nvnameeq("method", &oframe.nva[0]));
@ -183,7 +187,9 @@ void test_nghttp2_frame_pack_headers_frame_too_large(void)
nvlen = nghttp2_nv_array_from_cstr(&nva, (const char**)big_hds);
nghttp2_hd_deflate_init(&deflater, NGHTTP2_HD_SIDE_CLIENT);
nghttp2_frame_headers_init(&frame, NGHTTP2_FLAG_END_STREAM, 1000000007,
nghttp2_frame_headers_init(&frame,
NGHTTP2_FLAG_END_STREAM|NGHTTP2_FLAG_END_HEADERS,
1000000007,
0, nva, nvlen);
framelen = nghttp2_frame_pack_headers(&buf, &buflen, &frame, &deflater);
CU_ASSERT_EQUAL(NGHTTP2_ERR_HEADER_COMP, framelen);