Fix compile error and test failures

This commit is contained in:
Tatsuhiro Tsujikawa 2014-02-11 16:12:26 +09:00
parent e78a2100ec
commit 109b8cedde
2 changed files with 14 additions and 7 deletions

View File

@ -79,6 +79,7 @@ void test_nghttp2_frame_pack_headers()
nghttp2_nv *nva;
ssize_t nvlen;
nva_out out;
ssize_t nv_offset;
nva_out_init(&out);
nghttp2_hd_deflate_init(&deflater, NGHTTP2_HD_SIDE_REQUEST);
@ -102,9 +103,10 @@ void test_nghttp2_frame_pack_headers()
/* We didn't include PRIORITY flag so priority is not packed */
CU_ASSERT(1 << 30 == oframe.pri);
CU_ASSERT(framelen - (ssize_t)bufoff - 8 ==
nv_offset = bufoff + NGHTTP2_FRAME_HEAD_LENGTH;
CU_ASSERT(framelen - nv_offset ==
inflate_hd(&inflater, &out,
buf + bufoff + 8, framelen - bufoff - 8));
buf + nv_offset, framelen - nv_offset));
CU_ASSERT(7 == out.nvlen);
CU_ASSERT(nvnameeq("method", &out.nva[0]));
@ -128,8 +130,10 @@ void test_nghttp2_frame_pack_headers()
1000000007, &oframe.hd);
CU_ASSERT(1 << 20 == oframe.pri);
CU_ASSERT(framelen - 12 ==
inflate_hd(&inflater, &out, buf + 12, framelen - 12));
nv_offset = bufoff + NGHTTP2_FRAME_HEAD_LENGTH + 4;
CU_ASSERT(framelen - nv_offset ==
inflate_hd(&inflater, &out,
buf + nv_offset, framelen - nv_offset));
nghttp2_nv_array_sort(out.nva, out.nvlen);
CU_ASSERT(nvnameeq("method", &out.nva[0]));

View File

@ -797,6 +797,7 @@ void test_nghttp2_session_recv_premature_headers(void)
my_user_data ud;
nghttp2_hd_deflater deflater;
nghttp2_outbound_item *item;
size_t bufoff = 0;
memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));
@ -808,14 +809,16 @@ void test_nghttp2_session_recv_premature_headers(void)
nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS,
1, NGHTTP2_PRI_DEFAULT, nva, nvlen);
framedatalen = nghttp2_frame_pack_headers(&framedata, &framedatacap,
&bufoff,
&frame.headers,
&deflater);
nghttp2_frame_headers_free(&frame.headers);
/* Intentionally feed payload cutting last 1 byte off */
nghttp2_put_uint16be(framedata, frame.hd.length - 1);
rv = nghttp2_session_mem_recv(session, framedata, framedatalen - 1);
CU_ASSERT((ssize_t)framedatalen - 1 == rv);
nghttp2_put_uint16be(framedata + bufoff, frame.hd.length - 1);
rv = nghttp2_session_mem_recv(session, framedata + bufoff,
framedatalen - bufoff - 1);
CU_ASSERT((ssize_t)framedatalen - bufoff - 1 == rv);
item = nghttp2_session_get_next_ob_item(session);
CU_ASSERT(NULL != item);