|
|
|
|
@@ -121,6 +121,7 @@ void UT_Parse_ReqHeaders(nghttp2_session *as_server)
|
|
|
|
|
field_name.field_id = TFE_HTTP_DATE;
|
|
|
|
|
hdr_value = tfe_http_field_read((const struct tfe_http_half*)tfe_half, &field_name);
|
|
|
|
|
EXPECT_STREQ(hdr_value, "201x101x");
|
|
|
|
|
xret = tfe_http_field_write(tfe_half, &field_name, NULL); // delete field_name
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@@ -197,6 +198,10 @@ TEST(Http2StreamParser, GetFrameWithMagic)
|
|
|
|
|
/*Recv data magic**/
|
|
|
|
|
readlen = nghttp2_session_mem_recv(h2_stream_info->as_server, magic_headers, sizeof(magic_headers));
|
|
|
|
|
EXPECT_GT(readlen, 0);
|
|
|
|
|
|
|
|
|
|
sess_data_ctx_fini(tapinfo->h2_stream_info, NULL, 0);
|
|
|
|
|
free(tapinfo->h2_stream_info);
|
|
|
|
|
free(tapinfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(Http2StreamParser, GetFrameWithHeader_01)
|
|
|
|
|
@@ -219,6 +224,10 @@ TEST(Http2StreamParser, GetFrameWithHeader_01)
|
|
|
|
|
EXPECT_GT(readlen, 0);
|
|
|
|
|
|
|
|
|
|
UT_Parse_ReqHeaders(h2_stream_info->as_server);
|
|
|
|
|
|
|
|
|
|
sess_data_ctx_fini(tapinfo->h2_stream_info, NULL, 0);
|
|
|
|
|
free(tapinfo->h2_stream_info);
|
|
|
|
|
free(tapinfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(Http2StreamParser, GetFrameWithHeader_02)
|
|
|
|
|
@@ -244,6 +253,10 @@ TEST(Http2StreamParser, GetFrameWithHeader_02)
|
|
|
|
|
//enum tfe_stream_action stream_action = ACTION_FORWARD_DATA;
|
|
|
|
|
//stream_action = nghttp2_client_mem_send(h2_stream_info);
|
|
|
|
|
//EXPECT_EQ(stream_action, ACTION_DROP_DATA);
|
|
|
|
|
|
|
|
|
|
sess_data_ctx_fini(tapinfo->h2_stream_info, NULL, 0);
|
|
|
|
|
free(tapinfo->h2_stream_info);
|
|
|
|
|
free(tapinfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(Http2StreamParser, RespFrameWithHead_01)
|
|
|
|
|
@@ -278,6 +291,10 @@ TEST(Http2StreamParser, RespFrameWithHead_01)
|
|
|
|
|
readlen = nghttp2_session_mem_recv(h2_stream_info->as_client, response_header2, sizeof(response_header2));
|
|
|
|
|
EXPECT_GT(readlen, 0);
|
|
|
|
|
UT_Parse_RespHeaders(h2_stream_info->as_client);
|
|
|
|
|
|
|
|
|
|
sess_data_ctx_fini(tapinfo->h2_stream_info, NULL, 0);
|
|
|
|
|
free(tapinfo->h2_stream_info);
|
|
|
|
|
free(tapinfo);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
@@ -310,21 +327,23 @@ TEST(Http2StreamParser, FrameWithJdData)
|
|
|
|
|
action = detect_up_stream_protocol(h2_stream_info, NULL, 0, data[len], datalen[len]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sess_data_ctx_fini(tapinfo->h2_stream_info, NULL, 0);
|
|
|
|
|
free(tapinfo->h2_stream_info);
|
|
|
|
|
free(tapinfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(UI_TEST_INFLATE_GZIP, inflate_01)
|
|
|
|
|
{
|
|
|
|
|
char *uncompr = NULL;
|
|
|
|
|
struct tfe_h2_payload body;
|
|
|
|
|
int ret = 0, uncompr_len = 0;
|
|
|
|
|
|
|
|
|
|
memset(&body, 0, sizeof(struct tfe_h2_payload));
|
|
|
|
|
|
|
|
|
|
ret = inflate_read(ut_gip_01, sizeof(ut_gip_01), &uncompr, &uncompr_len, &(body.inflate), 2);
|
|
|
|
|
struct z_stream_st *inflate = NULL;
|
|
|
|
|
ret = inflate_read(ut_gip_01, sizeof(ut_gip_01), &uncompr, &uncompr_len, &inflate, 2);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(ret, Z_STREAM_END);
|
|
|
|
|
EXPECT_EQ(uncompr_len, sizeof(ut_ungip_01));
|
|
|
|
|
EXPECT_EQ(memcmp(uncompr, ut_ungip_01, sizeof(ut_ungip_01)), 0);
|
|
|
|
|
inflate_finished(&inflate);
|
|
|
|
|
|
|
|
|
|
free(uncompr);
|
|
|
|
|
uncompr = NULL;
|
|
|
|
|
@@ -332,26 +351,26 @@ TEST(UI_TEST_INFLATE_GZIP, inflate_01)
|
|
|
|
|
|
|
|
|
|
TEST(UI_TEST_INFLATE_GZIP, inflate_02)
|
|
|
|
|
{
|
|
|
|
|
struct tfe_h2_payload body;
|
|
|
|
|
struct z_stream_st *inflate = NULL;
|
|
|
|
|
int ret = 0, half = 0;
|
|
|
|
|
int size = sizeof(ut_gip_01);
|
|
|
|
|
half = size / 2;
|
|
|
|
|
|
|
|
|
|
body.inflate = NULL;
|
|
|
|
|
|
|
|
|
|
char *uncompr1 = NULL; int uncompr_len1 = 0;
|
|
|
|
|
ret = inflate_read(ut_gip_01, half, &uncompr1, &uncompr_len1, &(body.inflate), 2);
|
|
|
|
|
ret = inflate_read(ut_gip_01, half, &uncompr1, &uncompr_len1, &inflate, 2);
|
|
|
|
|
EXPECT_EQ(ret, Z_OK);
|
|
|
|
|
|
|
|
|
|
char *uncompr2 = NULL; int uncompr_len2 = 0;
|
|
|
|
|
ret = inflate_read(ut_gip_01 + half, size - half, &uncompr2, &uncompr_len2, &(body.inflate), 2);
|
|
|
|
|
ret = inflate_read(ut_gip_01 + half, size - half, &uncompr2, &uncompr_len2, &inflate, 2);
|
|
|
|
|
EXPECT_EQ(ret, Z_STREAM_END);
|
|
|
|
|
|
|
|
|
|
char uncompr[1024] = {0};
|
|
|
|
|
snprintf(uncompr, 1024 -1, "%s%s", uncompr1, uncompr2);
|
|
|
|
|
memcpy(uncompr, uncompr1, uncompr_len1);
|
|
|
|
|
memcpy(uncompr + uncompr_len1, uncompr2, uncompr_len2);
|
|
|
|
|
EXPECT_EQ(uncompr_len1 + uncompr_len2, sizeof(ut_ungip_01));
|
|
|
|
|
//EXPECT_EQ(memcmp(uncompr, ut_ungip_01, sizeof(ut_ungip_01)), 0);
|
|
|
|
|
EXPECT_EQ(memcmp(uncompr, ut_ungip_01, sizeof(ut_ungip_01)), 0);
|
|
|
|
|
|
|
|
|
|
inflate_finished(&inflate);
|
|
|
|
|
free(uncompr1);
|
|
|
|
|
uncompr1 = NULL;
|
|
|
|
|
free(uncompr2);
|
|
|
|
|
@@ -361,26 +380,27 @@ TEST(UI_TEST_INFLATE_GZIP, inflate_02)
|
|
|
|
|
TEST(UI_TEST_DEFLATE_GZIP, deflate_01)
|
|
|
|
|
{
|
|
|
|
|
unsigned char *dest = NULL;
|
|
|
|
|
struct tfe_h2_payload body;
|
|
|
|
|
int ret = 0, dlen = 0;
|
|
|
|
|
struct evbuffer * buf = evbuffer_new();
|
|
|
|
|
int size = sizeof(ut_ungip_01);
|
|
|
|
|
|
|
|
|
|
memset(&body, 0, sizeof(struct tfe_h2_payload));
|
|
|
|
|
|
|
|
|
|
ret = deflate_write(&(body.deflate), ut_ungip_01, size, buf, 2, 1);
|
|
|
|
|
struct z_stream_st *deflate = NULL;
|
|
|
|
|
ret = deflate_write(&deflate, ut_ungip_01, size, buf, 2, 1);
|
|
|
|
|
EXPECT_EQ(ret, Z_OK);
|
|
|
|
|
deflate_finished(&deflate);
|
|
|
|
|
|
|
|
|
|
dest = evbuffer_pullup(buf, -1);
|
|
|
|
|
dlen = evbuffer_get_length(buf);
|
|
|
|
|
|
|
|
|
|
char *uncompr = NULL;
|
|
|
|
|
int uncompr_len = 0;
|
|
|
|
|
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &(body.inflate), 2);
|
|
|
|
|
struct z_stream_st *inflate = NULL;
|
|
|
|
|
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &inflate, 2);
|
|
|
|
|
EXPECT_EQ(ret, Z_STREAM_END);
|
|
|
|
|
EXPECT_EQ(uncompr_len, sizeof(ut_ungip_01));
|
|
|
|
|
EXPECT_EQ(memcmp(uncompr, ut_ungip_01, sizeof(ut_ungip_01)), 0);
|
|
|
|
|
|
|
|
|
|
inflate_finished(&inflate);
|
|
|
|
|
free(uncompr);
|
|
|
|
|
uncompr = NULL;
|
|
|
|
|
evbuffer_free(buf);
|
|
|
|
|
@@ -388,7 +408,6 @@ TEST(UI_TEST_DEFLATE_GZIP, deflate_01)
|
|
|
|
|
|
|
|
|
|
TEST(UI_TEST_DEFLATE_GZIP, deflate_02)
|
|
|
|
|
{
|
|
|
|
|
struct tfe_h2_payload body;
|
|
|
|
|
unsigned char *dest = NULL;
|
|
|
|
|
int ret = 0, half = 0, dlen = 0;
|
|
|
|
|
|
|
|
|
|
@@ -396,30 +415,31 @@ TEST(UI_TEST_DEFLATE_GZIP, deflate_02)
|
|
|
|
|
half = size / 2;
|
|
|
|
|
|
|
|
|
|
struct evbuffer * buf = evbuffer_new();
|
|
|
|
|
|
|
|
|
|
memset(&body, 0, sizeof(struct tfe_h2_payload));
|
|
|
|
|
|
|
|
|
|
struct z_stream_st *deflate = NULL;
|
|
|
|
|
/* First frag */
|
|
|
|
|
ret = deflate_write(&(body.deflate), ut_ungip_01, half, buf, 2, 0);
|
|
|
|
|
ret = deflate_write(&deflate, ut_ungip_01, half, buf, 2, 0);
|
|
|
|
|
EXPECT_EQ(ret, Z_OK);
|
|
|
|
|
|
|
|
|
|
/* Last frag */
|
|
|
|
|
ret = deflate_write(&(body.deflate), ut_ungip_01 + half, size - half, buf, 2, 0);
|
|
|
|
|
ret = deflate_write(&deflate, ut_ungip_01 + half, size - half, buf, 2, 0);
|
|
|
|
|
EXPECT_EQ(ret, Z_OK);
|
|
|
|
|
|
|
|
|
|
/* End frag */
|
|
|
|
|
ret = deflate_write(&(body.deflate), NULL, 0, buf, 2, 1);
|
|
|
|
|
ret = deflate_write(&deflate, NULL, 0, buf, 2, 1);
|
|
|
|
|
EXPECT_EQ(ret, Z_OK);
|
|
|
|
|
deflate_finished(&deflate);
|
|
|
|
|
|
|
|
|
|
dest = evbuffer_pullup(buf, -1);
|
|
|
|
|
dlen = evbuffer_get_length(buf);
|
|
|
|
|
|
|
|
|
|
char *uncompr = NULL;
|
|
|
|
|
int uncompr_len = 0;
|
|
|
|
|
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &(body.inflate), 2);
|
|
|
|
|
struct z_stream_st *inflate = NULL;
|
|
|
|
|
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &inflate, 2);
|
|
|
|
|
EXPECT_EQ(ret, Z_STREAM_END);
|
|
|
|
|
EXPECT_EQ(uncompr_len, sizeof(ut_ungip_01));
|
|
|
|
|
EXPECT_EQ(memcmp(uncompr, ut_ungip_01, sizeof(ut_ungip_01)), 0);
|
|
|
|
|
inflate_finished(&inflate);
|
|
|
|
|
|
|
|
|
|
free(uncompr);
|
|
|
|
|
uncompr = NULL;
|
|
|
|
|
@@ -429,25 +449,26 @@ TEST(UI_TEST_DEFLATE_GZIP, deflate_02)
|
|
|
|
|
TEST(UI_TEST_DEFLATE_BR, deflate_01)
|
|
|
|
|
{
|
|
|
|
|
unsigned char *dest = NULL;
|
|
|
|
|
struct tfe_h2_payload body;
|
|
|
|
|
int ret = 0, dlen = 0;
|
|
|
|
|
struct evbuffer * buf = evbuffer_new();
|
|
|
|
|
int size = sizeof(ut_ungip_01);
|
|
|
|
|
|
|
|
|
|
memset(&body, 0, sizeof(struct tfe_h2_payload));
|
|
|
|
|
|
|
|
|
|
ret = deflate_write(&(body.deflate), ut_ungip_01, size, buf, HTTP2_CONTENT_ENCODING_BR, 1);
|
|
|
|
|
struct z_stream_st *deflate = NULL;
|
|
|
|
|
ret = deflate_write(&deflate, ut_ungip_01, size, buf, HTTP2_CONTENT_ENCODING_BR, 1);
|
|
|
|
|
EXPECT_EQ(ret, Z_OK);
|
|
|
|
|
deflate_finished(&deflate);
|
|
|
|
|
|
|
|
|
|
dest = evbuffer_pullup(buf, -1);
|
|
|
|
|
dlen = evbuffer_get_length(buf);
|
|
|
|
|
|
|
|
|
|
char *uncompr = NULL;
|
|
|
|
|
int uncompr_len = 0;
|
|
|
|
|
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &(body.inflate), HTTP2_CONTENT_ENCODING_BR);
|
|
|
|
|
struct z_stream_st *inflate = NULL;
|
|
|
|
|
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &inflate, HTTP2_CONTENT_ENCODING_BR);
|
|
|
|
|
EXPECT_EQ(ret, Z_STREAM_END);
|
|
|
|
|
EXPECT_EQ(uncompr_len, sizeof(ut_ungip_01));
|
|
|
|
|
EXPECT_EQ(memcmp(uncompr, ut_ungip_01, sizeof(ut_ungip_01)), 0);
|
|
|
|
|
inflate_finished(&inflate);
|
|
|
|
|
|
|
|
|
|
free(uncompr);
|
|
|
|
|
uncompr = NULL;
|
|
|
|
|
@@ -456,7 +477,6 @@ TEST(UI_TEST_DEFLATE_BR, deflate_01)
|
|
|
|
|
|
|
|
|
|
TEST(UI_TEST_DEFLATE_BR, deflate_02)
|
|
|
|
|
{
|
|
|
|
|
struct tfe_h2_payload body;
|
|
|
|
|
unsigned char *dest = NULL;
|
|
|
|
|
int ret = 0, half = 0, dlen = 0;
|
|
|
|
|
|
|
|
|
|
@@ -464,30 +484,31 @@ TEST(UI_TEST_DEFLATE_BR, deflate_02)
|
|
|
|
|
half = size / 2;
|
|
|
|
|
|
|
|
|
|
struct evbuffer * buf = evbuffer_new();
|
|
|
|
|
|
|
|
|
|
memset(&body, 0, sizeof(struct tfe_h2_payload));
|
|
|
|
|
|
|
|
|
|
struct z_stream_st *deflate = NULL;
|
|
|
|
|
/* First frag */
|
|
|
|
|
ret = deflate_write(&(body.deflate), ut_ungip_01, half, buf, HTTP2_CONTENT_ENCODING_BR, 0);
|
|
|
|
|
ret = deflate_write(&deflate, ut_ungip_01, half, buf, HTTP2_CONTENT_ENCODING_BR, 0);
|
|
|
|
|
EXPECT_EQ(ret, Z_OK);
|
|
|
|
|
|
|
|
|
|
/* Last frag */
|
|
|
|
|
ret = deflate_write(&(body.deflate), ut_ungip_01 + half, size - half, buf, HTTP2_CONTENT_ENCODING_BR, 0);
|
|
|
|
|
ret = deflate_write(&deflate, ut_ungip_01 + half, size - half, buf, HTTP2_CONTENT_ENCODING_BR, 0);
|
|
|
|
|
EXPECT_EQ(ret, Z_OK);
|
|
|
|
|
|
|
|
|
|
/* End frag */
|
|
|
|
|
ret = deflate_write(&(body.deflate), NULL, 0, buf, HTTP2_CONTENT_ENCODING_BR, 1);
|
|
|
|
|
ret = deflate_write(&deflate, NULL, 0, buf, HTTP2_CONTENT_ENCODING_BR, 1);
|
|
|
|
|
EXPECT_EQ(ret, Z_OK);
|
|
|
|
|
deflate_finished(&deflate);
|
|
|
|
|
|
|
|
|
|
dest = evbuffer_pullup(buf, -1);
|
|
|
|
|
dlen = evbuffer_get_length(buf);
|
|
|
|
|
|
|
|
|
|
char *uncompr = NULL;
|
|
|
|
|
int uncompr_len = 0;
|
|
|
|
|
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &(body.inflate), HTTP2_CONTENT_ENCODING_BR);
|
|
|
|
|
struct z_stream_st *inflate = NULL;
|
|
|
|
|
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &inflate, HTTP2_CONTENT_ENCODING_BR);
|
|
|
|
|
EXPECT_EQ(ret, Z_STREAM_END);
|
|
|
|
|
EXPECT_EQ(uncompr_len, sizeof(ut_ungip_01));
|
|
|
|
|
EXPECT_EQ(memcmp(uncompr, ut_ungip_01, sizeof(ut_ungip_01)), 0);
|
|
|
|
|
inflate_finished(&inflate);
|
|
|
|
|
|
|
|
|
|
free(uncompr);
|
|
|
|
|
uncompr = NULL;
|
|
|
|
|
|