tests: Add test for header compression without indexing
This commit is contained in:
parent
2d08d30409
commit
8cd2b57f8a
|
@ -233,10 +233,14 @@ int main(int argc, char* argv[])
|
|||
test_nghttp2_hd_deflate_common_header_eviction) ||
|
||||
!CU_add_test(pSuite, "hd_deflate_deflate_buffer",
|
||||
test_nghttp2_hd_deflate_deflate_buffer) ||
|
||||
!CU_add_test(pSuite, "hd_inflate_indname_noinc",
|
||||
test_nghttp2_hd_inflate_indname_noinc) ||
|
||||
!CU_add_test(pSuite, "hd_inflate_indname_inc",
|
||||
test_nghttp2_hd_inflate_indname_inc) ||
|
||||
!CU_add_test(pSuite, "hd_inflate_indname_inc_eviction",
|
||||
test_nghttp2_hd_inflate_indname_inc_eviction) ||
|
||||
!CU_add_test(pSuite, "hd_inflate_newname_noinc",
|
||||
test_nghttp2_hd_inflate_newname_noinc) ||
|
||||
!CU_add_test(pSuite, "hd_inflate_newname_inc",
|
||||
test_nghttp2_hd_inflate_newname_inc) ||
|
||||
!CU_add_test(pSuite, "hd_inflate_clearall_inc",
|
||||
|
|
|
@ -438,6 +438,41 @@ void test_nghttp2_hd_deflate_deflate_buffer(void)
|
|||
|
||||
}
|
||||
|
||||
void test_nghttp2_hd_inflate_indname_noinc(void)
|
||||
{
|
||||
nghttp2_hd_context inflater;
|
||||
uint8_t *buf = NULL;
|
||||
size_t buflen = 0;
|
||||
size_t offset = 0;
|
||||
nghttp2_nv nv[] = {
|
||||
/* Huffman */
|
||||
MAKE_NV("user-agent", "nghttp2"),
|
||||
/* Expecting no huffman */
|
||||
MAKE_NV("user-agent", "x")
|
||||
};
|
||||
nghttp2_nv *resnva;
|
||||
size_t i;
|
||||
|
||||
nghttp2_hd_inflate_init(&inflater, NGHTTP2_HD_SIDE_REQUEST);
|
||||
|
||||
for(i = 0; i < ARRLEN(nv); ++i) {
|
||||
offset = 0;
|
||||
CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&buf, &buflen, &offset, 55,
|
||||
nv[i].value, nv[i].valuelen,
|
||||
0,
|
||||
NGHTTP2_HD_SIDE_REQUEST));
|
||||
CU_ASSERT(1 == nghttp2_hd_inflate_hd(&inflater, &resnva, buf, offset));
|
||||
assert_nv_equal(&nv[i], resnva, 1);
|
||||
CU_ASSERT(0 == inflater.hd_table.len);
|
||||
|
||||
nghttp2_nv_array_del(resnva);
|
||||
nghttp2_hd_end_headers(&inflater);
|
||||
}
|
||||
|
||||
free(buf);
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
}
|
||||
|
||||
void test_nghttp2_hd_inflate_indname_inc(void)
|
||||
{
|
||||
nghttp2_hd_context inflater;
|
||||
|
@ -501,6 +536,43 @@ void test_nghttp2_hd_inflate_indname_inc_eviction(void)
|
|||
nghttp2_hd_inflate_free(&inflater);
|
||||
}
|
||||
|
||||
void test_nghttp2_hd_inflate_newname_noinc(void)
|
||||
{
|
||||
nghttp2_hd_context inflater;
|
||||
uint8_t *buf = NULL;
|
||||
size_t buflen = 0;
|
||||
size_t offset = 0;
|
||||
nghttp2_nv nv[] = {
|
||||
/* Expecting huffman for both */
|
||||
MAKE_NV("my-long-content-length", "nghttp2"),
|
||||
/* Expecting no huffman for both */
|
||||
MAKE_NV("x", "y"),
|
||||
/* Huffman for key only */
|
||||
MAKE_NV("my-long-content-length", "y"),
|
||||
/* Huffman for value only */
|
||||
MAKE_NV("x", "nghttp2")
|
||||
};
|
||||
nghttp2_nv *resnva;
|
||||
size_t i;
|
||||
|
||||
nghttp2_hd_inflate_init(&inflater, NGHTTP2_HD_SIDE_REQUEST);
|
||||
for(i = 0; i < ARRLEN(nv); ++i) {
|
||||
offset = 0;
|
||||
CU_ASSERT(0 == nghttp2_hd_emit_newname_block(&buf, &buflen, &offset,
|
||||
&nv[i], 0,
|
||||
NGHTTP2_HD_SIDE_REQUEST));
|
||||
CU_ASSERT(1 == nghttp2_hd_inflate_hd(&inflater, &resnva, buf, offset));
|
||||
assert_nv_equal(&nv[i], resnva, 1);
|
||||
CU_ASSERT(0 == inflater.hd_table.len);
|
||||
|
||||
nghttp2_nv_array_del(resnva);
|
||||
nghttp2_hd_end_headers(&inflater);
|
||||
}
|
||||
|
||||
free(buf);
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
}
|
||||
|
||||
void test_nghttp2_hd_inflate_newname_inc(void)
|
||||
{
|
||||
nghttp2_hd_context inflater;
|
||||
|
|
|
@ -29,8 +29,10 @@ void test_nghttp2_hd_deflate(void);
|
|||
void test_nghttp2_hd_deflate_same_indexed_repr(void);
|
||||
void test_nghttp2_hd_deflate_common_header_eviction(void);
|
||||
void test_nghttp2_hd_deflate_deflate_buffer(void);
|
||||
void test_nghttp2_hd_inflate_indname_noinc(void);
|
||||
void test_nghttp2_hd_inflate_indname_inc(void);
|
||||
void test_nghttp2_hd_inflate_indname_inc_eviction(void);
|
||||
void test_nghttp2_hd_inflate_newname_noinc(void);
|
||||
void test_nghttp2_hd_inflate_newname_inc(void);
|
||||
void test_nghttp2_hd_inflate_clearall_inc(void);
|
||||
void test_nghttp2_hd_change_table_size(void);
|
||||
|
|
Loading…
Reference in New Issue