1.删除缓存测试无效代码
2.修改header链表结构为TQ 3,重构h2_half_ops_field_read,h2_half_ops_field_write等接口
This commit is contained in:
@@ -333,7 +333,7 @@ size_t insert_string(char * in, size_t in_sz, const char *insert_on, const char
|
||||
offset+=concat_len;
|
||||
memcpy(target+offset, insert_from, in_sz-(insert_from-in));
|
||||
offset+=in_sz-(insert_from-in);
|
||||
assert(target_size==offset+1);
|
||||
assert(target_size==offset);
|
||||
|
||||
free(concat_style);
|
||||
concat_style = NULL;
|
||||
|
||||
@@ -280,7 +280,7 @@ static int __hf_content_compress_write_zlib(struct hf_content_compress * cv_obje
|
||||
|
||||
/* Reserve the space, because the length of the compressed data will be short
|
||||
* than uncompressed data in usually, we set the reserve space as much as sz_in_data */
|
||||
size_t __sz_reserve_chunk = sz_in_data > SZ_RESERVE_SPACE ? sz_in_data : SZ_RESERVE_SPACE;
|
||||
size_t __sz_reserve_chunk = MAX(sz_in_data, SZ_RESERVE_SPACE);
|
||||
int iov_count = evbuffer_reserve_space(out_ev_buf, __sz_reserve_chunk, v, 1);
|
||||
if (iov_count != 1) return -1;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ typedef struct RTLogInit2Data_ {
|
||||
|
||||
typedef struct Http2Plugin_{
|
||||
struct event * event[TFE_THREAD_MAX];
|
||||
struct tfe_session_info_t session_info[TFE_THREAD_MAX];
|
||||
struct tfe_h2_stream h2_stream[TFE_THREAD_MAX];
|
||||
} Http2Plugin;
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
> File Name: http_stream.h
|
||||
> Author:
|
||||
> Mail:
|
||||
> Created Time: 2018年09月12日 星期三 15时56分05秒
|
||||
> Created Time: 2018<EFBFBD><EFBFBD>?09<30><39>?12<31><32>? 星期<E6989F><E69C9F>? 15<31><35>?56<35><36>?05<30><35>?
|
||||
************************************************************************/
|
||||
|
||||
#ifndef _HTTP_STREAM_H
|
||||
@@ -14,41 +14,40 @@
|
||||
#include <nghttp2/nghttp2.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
typedef int (*event_cb)(struct http2_half_private * hf_private,
|
||||
typedef int (*event_cb)(struct tfe_h2_half_private * hf_private,
|
||||
tfe_http_event ev, const unsigned char * data,
|
||||
size_t len, void * user);
|
||||
|
||||
enum nghttp2_manage_stage
|
||||
enum h2_read_state
|
||||
{
|
||||
MANAGE_STAGE_INIT,
|
||||
MANAGE_STAGE_READING,
|
||||
MANAGE_STAGE_COMPLETE,
|
||||
H2_READ_STATE_BEGIN,
|
||||
H2_READ_STATE_READING,
|
||||
H2_READ_STATE_COMPLETE,
|
||||
};
|
||||
|
||||
struct data_t
|
||||
struct tfe_h2_payload
|
||||
{
|
||||
int gzip;
|
||||
uint8_t flags;
|
||||
ssize_t padlen;
|
||||
struct z_stream_st *inflater;
|
||||
struct z_stream_st *inflate;
|
||||
struct z_stream_st *deflate;
|
||||
struct evbuffer * evbuf_body;
|
||||
};
|
||||
|
||||
struct header_data{
|
||||
struct tfe_h2_field{
|
||||
TAILQ_ENTRY(tfe_h2_field) next;
|
||||
nghttp2_nv nv;
|
||||
struct http_field_name field;
|
||||
struct header_data *prev, *next;
|
||||
struct http_field_name *field;
|
||||
};
|
||||
|
||||
struct http2_headers{
|
||||
struct tfe_h2_header{
|
||||
TAILQ_HEAD(h2_field_list_head, tfe_h2_field) h2_field_list;
|
||||
int nvlen;
|
||||
int complete;
|
||||
uint8_t flag;
|
||||
struct header_data *head, *tail;
|
||||
};
|
||||
|
||||
struct http2_half_private
|
||||
struct tfe_h2_half_private
|
||||
{
|
||||
/* PUBLIC STRUCTURE */
|
||||
struct tfe_http_half half_public;
|
||||
@@ -60,19 +59,20 @@ struct http2_half_private
|
||||
int by_stream;
|
||||
|
||||
char * url_storage;
|
||||
struct data_t body;
|
||||
struct http2_headers headers;
|
||||
struct http2_headers promised;
|
||||
struct tfe_h2_payload body;
|
||||
struct tfe_h2_header header;
|
||||
struct tfe_h2_header promised;
|
||||
|
||||
/*Read Cache**/
|
||||
int32_t stream_id;
|
||||
nghttp2_session *session;
|
||||
struct tfe_h2_session *father_session;
|
||||
|
||||
enum nghttp2_manage_stage body_state;
|
||||
enum nghttp2_manage_stage message_state;
|
||||
enum h2_read_state body_state;
|
||||
enum h2_read_state message_state;
|
||||
|
||||
/* Callback Function */
|
||||
int (*event_cb)(struct http2_half_private * half_private, tfe_http_event ev,
|
||||
int (*event_cb)(struct tfe_h2_half_private * half_private, tfe_http_event ev,
|
||||
const unsigned char * data, size_t len, void * user);
|
||||
/* Callback Function User Pointer */
|
||||
void * event_cb_user;
|
||||
@@ -84,35 +84,32 @@ struct cache_trapper_t{
|
||||
int spd_set;
|
||||
int spd_valid;
|
||||
int rse_set;
|
||||
//int set_cnt;
|
||||
//int flag_end;
|
||||
int spd_set_cnt;
|
||||
int spd_cnt;
|
||||
tfe_http_event spd_event;
|
||||
};
|
||||
|
||||
struct h2_stream_data_t{
|
||||
struct tfe_h2_session{
|
||||
struct tfe_http_session tfe_session;
|
||||
TAILQ_ENTRY(h2_stream_data_t) next;
|
||||
TAILQ_ENTRY(tfe_h2_session) next;
|
||||
const struct tfe_stream *tf_stream;
|
||||
|
||||
int32_t stream_id;
|
||||
int32_t ngh2_stream_id;
|
||||
nghttp2_session *session;
|
||||
struct tfe_h2_stream *father_stream;
|
||||
|
||||
struct cache_trapper_t cache;
|
||||
struct http_frame_session_ctx *frame_ctx;
|
||||
struct http2_half_private *req, *pangu_req;
|
||||
struct http2_half_private *resp, *pangu_resp;
|
||||
struct tfe_h2_half_private *req, *plugin_built_req;
|
||||
struct tfe_h2_half_private *resp, *plugin_built_resp;
|
||||
};
|
||||
|
||||
struct tfe_session_info_t
|
||||
struct tfe_h2_stream
|
||||
{
|
||||
TAILQ_HEAD(list_head, h2_stream_data_t) list;
|
||||
TAILQ_HEAD(list_head, tfe_h2_session) h2_session_list;
|
||||
|
||||
int goaway;
|
||||
|
||||
int32_t stream_id;
|
||||
|
||||
enum tfe_stream_action stream_action;
|
||||
|
||||
unsigned int thread_id;
|
||||
@@ -130,67 +127,52 @@ struct stream_tap_info_t
|
||||
/** IS PREEMPTED */
|
||||
unsigned int preempted;
|
||||
/** sess manage */
|
||||
struct tfe_session_info_t *session_info;
|
||||
struct tfe_h2_stream *h2_stream_info;
|
||||
};
|
||||
|
||||
/*STREAM STATE **/
|
||||
#define TFE_NGHTTP2_DATA 0x00000001
|
||||
#define TFE_NGHTTP2_HEADERS 0x00000002
|
||||
#define TFE_NGHTTP2_PRIORITY 0x00000020
|
||||
#define TFE_NGHTTP2_RST_STREAM 0x00000040
|
||||
#define TFE_NGHTTP2_SETTINGS 0x00000080
|
||||
#define TFE_NGHTTP2_PUSH_PROMISE 0x00000100
|
||||
#define TFE_NGHTTP2_PING 0x00000200
|
||||
#define TFE_NGHTTP2_GOAWAY 0x00000400
|
||||
#define TFE_NGHTTP2_WINDOW_UPDATE 0x00000800
|
||||
#define TFE_NGHTTP2_CONTINUATION 0x00001000
|
||||
#define TFE_NGHTTP2_ALTSVC 0x00002000
|
||||
#define TFE_NGHTTP2_RESPONSE 0x00004000
|
||||
|
||||
#define ACTION_USER_DATA 3
|
||||
#define NGHTTP2_NO_USER_ERROR 0x0e
|
||||
|
||||
static inline const struct http2_half_private *
|
||||
static inline const struct tfe_h2_half_private *
|
||||
nghttp2_to_half_private(const struct tfe_http_half * half_public)
|
||||
{
|
||||
if(!half_public)
|
||||
return NULL;
|
||||
return container_of(half_public, struct http2_half_private, half_public);
|
||||
return container_of(half_public, struct tfe_h2_half_private, half_public);
|
||||
}
|
||||
|
||||
static inline struct http2_half_private *
|
||||
static inline struct tfe_h2_half_private *
|
||||
nghttp2_to_half_private(struct tfe_http_half * half_public)
|
||||
{
|
||||
if(!half_public)
|
||||
return NULL;
|
||||
return container_of(half_public, struct http2_half_private, half_public);
|
||||
return container_of(half_public, struct tfe_h2_half_private, half_public);
|
||||
}
|
||||
|
||||
static inline struct h2_stream_data_t *
|
||||
static inline struct tfe_h2_session *
|
||||
nghttp2_to_stream_data(struct tfe_http_session * hs_public)
|
||||
{
|
||||
if (hs_public == NULL)
|
||||
return NULL;
|
||||
return container_of(hs_public, struct h2_stream_data_t, tfe_session);
|
||||
return container_of(hs_public, struct tfe_h2_session, tfe_session);
|
||||
}
|
||||
|
||||
extern struct tfe_session_info_t* tfe_session_info_init();
|
||||
extern void sess_data_ctx_fini(struct tfe_session_info_t *session_info, const struct tfe_stream * stream,
|
||||
extern struct tfe_h2_stream* tfe_session_info_init();
|
||||
extern void sess_data_ctx_fini(struct tfe_h2_stream *h2_stream_info, const struct tfe_stream * stream,
|
||||
unsigned int thread_id);
|
||||
|
||||
extern enum tfe_stream_action
|
||||
detect_down_stream_protocol(struct tfe_session_info_t *session_info, const struct tfe_stream *tfe_stream,
|
||||
detect_down_stream_protocol(struct tfe_h2_stream *h2_stream_info, const struct tfe_stream *tfe_stream,
|
||||
unsigned int thread_id, const unsigned char *data, size_t len);
|
||||
|
||||
extern enum tfe_stream_action
|
||||
detect_up_stream_protocol(struct tfe_session_info_t *session_info, const struct tfe_stream *tfe_stream,
|
||||
detect_up_stream_protocol(struct tfe_h2_stream *h2_stream_info, const struct tfe_stream *tfe_stream,
|
||||
unsigned int thread_id, const unsigned char *data, size_t len);
|
||||
|
||||
enum tfe_stream_action
|
||||
nghttp2_client_mem_send(struct tfe_session_info_t *session_info);
|
||||
nghttp2_client_mem_send(struct tfe_h2_stream *h2_stream_info);
|
||||
|
||||
enum tfe_stream_action
|
||||
nghttp2_server_mem_send(struct tfe_session_info_t *session_info);
|
||||
nghttp2_server_mem_send(struct tfe_h2_stream *h2_stream_info);
|
||||
|
||||
/*for test **/
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ str_to_val_idx(const char *val, const struct value_string *vs)
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
@@ -257,7 +257,7 @@ int deflate_init(struct z_stream_st **strm, int gzip)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int defalta_br_write(struct z_stream_st **strm,
|
||||
int deflate_br_write(struct z_stream_st **strm,
|
||||
const unsigned char * source, size_t slen,
|
||||
struct evbuffer * evbuf, int end)
|
||||
{
|
||||
@@ -363,7 +363,7 @@ int deflate_write(struct z_stream_st **strm, const uint8_t *source,
|
||||
ret = defalta_gzip_write(strm, source, slen, evbuf, end);
|
||||
}
|
||||
if (gzip == HTTP2_CONTENT_ENCODING_BR){
|
||||
ret = defalta_br_write(strm, source, slen, evbuf, end);
|
||||
ret = deflate_br_write(strm, source, slen, evbuf, end);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -61,8 +61,8 @@ void load_logging_conf(const char *config)
|
||||
|
||||
UNUSED static void http2_plugin_timer_gc_cb(evutil_socket_t fd, short what, void * arg)
|
||||
{
|
||||
struct tfe_session_info_t *session_info = (struct tfe_session_info_t *)arg;
|
||||
sess_data_ctx_fini(session_info, NULL, session_info->thread_id);
|
||||
struct tfe_h2_stream *h2_stream_info = (struct tfe_h2_stream *)arg;
|
||||
sess_data_ctx_fini(h2_stream_info, NULL, h2_stream_info->thread_id);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -76,15 +76,15 @@ http2_plugin_init(struct tfe_proxy * proxy)
|
||||
|
||||
for (unsigned int thread_id = 0; thread_id < thread_nu; thread_id++){
|
||||
#if 0
|
||||
struct tfe_session_info_t session_info = plugin->session_info[thread_id];
|
||||
TAILQ_INIT(&(session_info.list));
|
||||
session_info.thread_id = thread_id;
|
||||
session_info.as_client = 0;
|
||||
struct tfe_session_info_t h2_stream_info = plugin->h2_stream_info[thread_id];
|
||||
TAILQ_INIT(&(h2_stream_info.list));
|
||||
h2_stream_info.thread_id = thread_id;
|
||||
h2_stream_info.as_client = 0;
|
||||
|
||||
struct event_base * ev_base = tfe_proxy_get_work_thread_evbase(thread_id);
|
||||
|
||||
struct timeval timer = {0, 500 * 1000};
|
||||
struct event * event = event_new(ev_base, -1, EV_PERSIST, http2_plugin_timer_gc_cb, &session_info);
|
||||
struct event * event = event_new(ev_base, -1, EV_PERSIST, http2_plugin_timer_gc_cb, &h2_stream_info);
|
||||
|
||||
if (unlikely(event == NULL)){
|
||||
TFE_LOG_ERROR(logger()->handle, "Create timer error, init failed!");
|
||||
@@ -113,7 +113,7 @@ http2_stream_open(const struct tfe_stream *stream, unsigned int thread_id,
|
||||
|
||||
memset(tapinfo, 0, sizeof(struct stream_tap_info_t));
|
||||
tapinfo->preempted = 0;
|
||||
tapinfo->session_info = tfe_session_info_init();
|
||||
tapinfo->h2_stream_info = tfe_session_info_init();
|
||||
|
||||
*pme = (void *)tapinfo;
|
||||
|
||||
@@ -180,8 +180,8 @@ http2_stream_data(const struct tfe_stream * stream, unsigned int thread_id,
|
||||
tapinfo->preempted = 1;
|
||||
}
|
||||
|
||||
return (dir == CONN_DIR_DOWNSTREAM) ? detect_down_stream_protocol(tapinfo->session_info, stream, thread_id,
|
||||
data, len) : detect_up_stream_protocol(tapinfo->session_info, stream, thread_id, data, len);
|
||||
return (dir == CONN_DIR_DOWNSTREAM) ? detect_down_stream_protocol(tapinfo->h2_stream_info, stream, thread_id,
|
||||
data, len) : detect_up_stream_protocol(tapinfo->h2_stream_info, stream, thread_id, data, len);
|
||||
|
||||
detach:
|
||||
tfe_stream_detach(stream);
|
||||
@@ -195,10 +195,10 @@ http2_stream_close(const struct tfe_stream * stream, unsigned int thread_id,
|
||||
{
|
||||
struct stream_tap_info_t *tapinfo = (struct stream_tap_info_t *)(*pme);
|
||||
|
||||
sess_data_ctx_fini(tapinfo->session_info, stream, thread_id);
|
||||
sess_data_ctx_fini(tapinfo->h2_stream_info, stream, thread_id);
|
||||
|
||||
free(tapinfo->session_info);
|
||||
tapinfo->session_info = NULL;
|
||||
free(tapinfo->h2_stream_info);
|
||||
tapinfo->h2_stream_info = NULL;
|
||||
|
||||
free(tapinfo);
|
||||
tapinfo = NULL;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -57,10 +57,10 @@ void UT_Parse_ReqHeaders(nghttp2_session *as_server)
|
||||
{
|
||||
int stream_id = 1;
|
||||
|
||||
struct h2_stream_data_t *h2_stream = (struct h2_stream_data_t *)nghttp2_session_get_stream_user_data(as_server, stream_id);
|
||||
ASSERT_TRUE(h2_stream != NULL);
|
||||
struct tfe_h2_session *h2_session = (struct tfe_h2_session *)nghttp2_session_get_stream_user_data(as_server, stream_id);
|
||||
ASSERT_TRUE(h2_session != NULL);
|
||||
|
||||
struct http2_half_private *half_private_req = h2_stream->req;
|
||||
struct tfe_h2_half_private *half_private_req = h2_session->req;
|
||||
struct tfe_http_half *tfe_half = &half_private_req->half_public;
|
||||
struct tfe_http_req_spec *req_spec = &tfe_half->req_spec;
|
||||
|
||||
@@ -124,10 +124,10 @@ void UT_Parse_RespHeaders(nghttp2_session *as_client)
|
||||
{
|
||||
int stream_id = 1;
|
||||
|
||||
struct h2_stream_data_t *h2_stream = (struct h2_stream_data_t *)nghttp2_session_get_stream_user_data(as_client, stream_id);
|
||||
ASSERT_TRUE(h2_stream != NULL);
|
||||
struct tfe_h2_session *h2_session = (struct tfe_h2_session *)nghttp2_session_get_stream_user_data(as_client, stream_id);
|
||||
ASSERT_TRUE(h2_session != NULL);
|
||||
|
||||
struct http2_half_private *half_private_req = h2_stream->resp;
|
||||
struct tfe_h2_half_private *half_private_req = h2_session->resp;
|
||||
struct tfe_http_half *tfe_half = &half_private_req->half_public;
|
||||
struct tfe_http_resp_spec *resp_spec = &tfe_half->resp_spec;
|
||||
|
||||
@@ -181,16 +181,16 @@ TEST(Http2StreamParser, GetFrameWithMagic)
|
||||
struct stream_tap_info_t *tapinfo = ALLOC(struct stream_tap_info_t, 1);
|
||||
assert(tapinfo);
|
||||
|
||||
tapinfo->session_info = tfe_session_info_init();
|
||||
ASSERT_FALSE(tapinfo->session_info == NULL);
|
||||
tapinfo->h2_stream_info = tfe_session_info_init();
|
||||
ASSERT_FALSE(tapinfo->h2_stream_info == NULL);
|
||||
|
||||
struct tfe_session_info_t *session_info = tapinfo->session_info;
|
||||
struct tfe_h2_stream *h2_stream_info = tapinfo->h2_stream_info;
|
||||
|
||||
/*Http2 protocol**/
|
||||
EXPECT_EQ(memcmp(magic_headers, kMagicHello, MAGIC_FRAME_LENGTH), 0);
|
||||
|
||||
/*Recv data magic**/
|
||||
readlen = nghttp2_session_mem_recv(session_info->as_server, magic_headers, sizeof(magic_headers));
|
||||
readlen = nghttp2_session_mem_recv(h2_stream_info->as_server, magic_headers, sizeof(magic_headers));
|
||||
EXPECT_GT(readlen, 0);
|
||||
}
|
||||
|
||||
@@ -200,20 +200,20 @@ TEST(Http2StreamParser, GetFrameWithHeader_01)
|
||||
struct stream_tap_info_t *tapinfo = ALLOC(struct stream_tap_info_t, 1);
|
||||
assert(tapinfo);
|
||||
|
||||
tapinfo->session_info = tfe_session_info_init();
|
||||
ASSERT_FALSE(tapinfo->session_info == NULL);
|
||||
tapinfo->h2_stream_info = tfe_session_info_init();
|
||||
ASSERT_FALSE(tapinfo->h2_stream_info == NULL);
|
||||
|
||||
struct tfe_session_info_t *session_info = tapinfo->session_info;
|
||||
struct tfe_h2_stream *h2_stream_info = tapinfo->h2_stream_info;
|
||||
|
||||
/*Recv data magic**/
|
||||
readlen = nghttp2_session_mem_recv(session_info->as_server, magic_headers, sizeof(magic_headers));
|
||||
readlen = nghttp2_session_mem_recv(h2_stream_info->as_server, magic_headers, sizeof(magic_headers));
|
||||
EXPECT_GT(readlen, 0);
|
||||
|
||||
/*Recv request Headers**/
|
||||
readlen = nghttp2_session_mem_recv(session_info->as_server, request_get_headers, sizeof(request_get_headers));
|
||||
readlen = nghttp2_session_mem_recv(h2_stream_info->as_server, request_get_headers, sizeof(request_get_headers));
|
||||
EXPECT_GT(readlen, 0);
|
||||
|
||||
UT_Parse_ReqHeaders(session_info->as_server);
|
||||
UT_Parse_ReqHeaders(h2_stream_info->as_server);
|
||||
}
|
||||
|
||||
TEST(Http2StreamParser, GetFrameWithHeader_02)
|
||||
@@ -222,22 +222,22 @@ TEST(Http2StreamParser, GetFrameWithHeader_02)
|
||||
struct stream_tap_info_t *tapinfo = ALLOC(struct stream_tap_info_t, 1);
|
||||
assert(tapinfo);
|
||||
|
||||
tapinfo->session_info = tfe_session_info_init();
|
||||
ASSERT_FALSE(tapinfo->session_info == NULL);
|
||||
tapinfo->h2_stream_info = tfe_session_info_init();
|
||||
ASSERT_FALSE(tapinfo->h2_stream_info == NULL);
|
||||
|
||||
struct tfe_session_info_t *session_info = tapinfo->session_info;
|
||||
struct tfe_h2_stream *h2_stream_info = tapinfo->h2_stream_info;
|
||||
|
||||
/*Recv data magic**/
|
||||
readlen = nghttp2_session_mem_recv(session_info->as_server, magic_headers, sizeof(magic_headers));
|
||||
readlen = nghttp2_session_mem_recv(h2_stream_info->as_server, magic_headers, sizeof(magic_headers));
|
||||
EXPECT_GT(readlen, 0);
|
||||
|
||||
/*Recv request Headers**/
|
||||
readlen = nghttp2_session_mem_recv(session_info->as_server, request_get_headers, sizeof(request_get_headers));
|
||||
readlen = nghttp2_session_mem_recv(h2_stream_info->as_server, request_get_headers, sizeof(request_get_headers));
|
||||
EXPECT_GT(readlen, 0);
|
||||
|
||||
/*Send data message**/
|
||||
//enum tfe_stream_action stream_action = ACTION_FORWARD_DATA;
|
||||
//stream_action = nghttp2_client_mem_send(session_info);
|
||||
//stream_action = nghttp2_client_mem_send(h2_stream_info);
|
||||
//EXPECT_EQ(stream_action, ACTION_DROP_DATA);
|
||||
}
|
||||
|
||||
@@ -247,32 +247,32 @@ TEST(Http2StreamParser, RespFrameWithHead_01)
|
||||
struct stream_tap_info_t *tapinfo = ALLOC(struct stream_tap_info_t, 1);
|
||||
assert(tapinfo);
|
||||
|
||||
tapinfo->session_info = tfe_session_info_init();
|
||||
ASSERT_FALSE(tapinfo->session_info == NULL);
|
||||
tapinfo->h2_stream_info = tfe_session_info_init();
|
||||
ASSERT_FALSE(tapinfo->h2_stream_info == NULL);
|
||||
|
||||
struct tfe_session_info_t *session_info = tapinfo->session_info;
|
||||
struct tfe_h2_stream *h2_stream_info = tapinfo->h2_stream_info;
|
||||
|
||||
/*Recv data magic**/
|
||||
readlen = nghttp2_session_mem_recv(session_info->as_server, magic_headers, sizeof(magic_headers));
|
||||
readlen = nghttp2_session_mem_recv(h2_stream_info->as_server, magic_headers, sizeof(magic_headers));
|
||||
EXPECT_GT(readlen, 0);
|
||||
|
||||
/*Recv request Headers**/
|
||||
readlen = nghttp2_session_mem_recv(session_info->as_server, request_get_headers, sizeof(request_get_headers));
|
||||
readlen = nghttp2_session_mem_recv(h2_stream_info->as_server, request_get_headers, sizeof(request_get_headers));
|
||||
EXPECT_GT(readlen, 0);
|
||||
|
||||
/*Send data head message**/
|
||||
//enum tfe_stream_action stream_action = ACTION_FORWARD_DATA;
|
||||
//stream_action = nghttp2_client_mem_send(session_info);
|
||||
//stream_action = nghttp2_client_mem_send(h2_stream_info);
|
||||
//EXPECT_EQ(stream_action, ACTION_DROP_DATA);
|
||||
|
||||
/*Recv response settings*/
|
||||
readlen = nghttp2_session_mem_recv(session_info->as_client, response_settings, sizeof(response_settings));
|
||||
readlen = nghttp2_session_mem_recv(h2_stream_info->as_client, response_settings, sizeof(response_settings));
|
||||
EXPECT_GT(readlen, 0);
|
||||
|
||||
/*Recv response Header*/
|
||||
readlen = nghttp2_session_mem_recv(session_info->as_client, response_header2, sizeof(response_header2));
|
||||
readlen = nghttp2_session_mem_recv(h2_stream_info->as_client, response_header2, sizeof(response_header2));
|
||||
EXPECT_GT(readlen, 0);
|
||||
UT_Parse_RespHeaders(session_info->as_client);
|
||||
UT_Parse_RespHeaders(h2_stream_info->as_client);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -291,18 +291,18 @@ TEST(Http2StreamParser, FrameWithJdData)
|
||||
struct stream_tap_info_t *tapinfo = ALLOC(struct stream_tap_info_t, 1);
|
||||
assert(tapinfo);
|
||||
|
||||
tapinfo->session_info = tfe_session_info_init();
|
||||
ASSERT_FALSE(tapinfo->session_info == NULL);
|
||||
tapinfo->h2_stream_info = tfe_session_info_init();
|
||||
ASSERT_FALSE(tapinfo->h2_stream_info == NULL);
|
||||
|
||||
struct tfe_session_info_t *session_info = tapinfo->session_info;
|
||||
struct tfe_h2_stream *h2_stream_info = tapinfo->h2_stream_info;
|
||||
|
||||
for (len = 0; len <= 7; len++){
|
||||
if (len > 0 && len < 4){
|
||||
printf("Proc down stream(%d)\n", len);
|
||||
action = detect_down_stream_protocol(session_info, NULL, 0, data[len], datalen[len]);
|
||||
action = detect_down_stream_protocol(h2_stream_info, NULL, 0, data[len], datalen[len]);
|
||||
}else{
|
||||
printf("Proc up stream(%d)\n", len);
|
||||
action = detect_up_stream_protocol(session_info, NULL, 0, data[len], datalen[len]);
|
||||
action = detect_up_stream_protocol(h2_stream_info, NULL, 0, data[len], datalen[len]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,12 +310,12 @@ TEST(Http2StreamParser, FrameWithJdData)
|
||||
TEST(UI_TEST_INFLATE_GZIP, inflate_01)
|
||||
{
|
||||
char *uncompr = NULL;
|
||||
struct data_t body;
|
||||
struct tfe_h2_payload body;
|
||||
int ret = 0, uncompr_len = 0;
|
||||
|
||||
memset(&body, 0, sizeof(struct data_t));
|
||||
memset(&body, 0, sizeof(struct tfe_h2_payload));
|
||||
|
||||
ret = inflate_read(ut_gip_01, sizeof(ut_gip_01), &uncompr, &uncompr_len, &(body.inflater), 2);
|
||||
ret = inflate_read(ut_gip_01, sizeof(ut_gip_01), &uncompr, &uncompr_len, &(body.inflate), 2);
|
||||
|
||||
EXPECT_EQ(ret, Z_STREAM_END);
|
||||
EXPECT_EQ(uncompr_len, sizeof(ut_ungip_01));
|
||||
@@ -327,19 +327,19 @@ TEST(UI_TEST_INFLATE_GZIP, inflate_01)
|
||||
|
||||
TEST(UI_TEST_INFLATE_GZIP, inflate_02)
|
||||
{
|
||||
struct data_t body;
|
||||
struct tfe_h2_payload body;
|
||||
int ret = 0, half = 0;
|
||||
int size = sizeof(ut_gip_01);
|
||||
half = size / 2;
|
||||
|
||||
body.inflater = NULL;
|
||||
body.inflate = NULL;
|
||||
|
||||
char *uncompr1 = NULL; int uncompr_len1 = 0;
|
||||
ret = inflate_read(ut_gip_01, half, &uncompr1, &uncompr_len1, &(body.inflater), 2);
|
||||
ret = inflate_read(ut_gip_01, half, &uncompr1, &uncompr_len1, &(body.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.inflater), 2);
|
||||
ret = inflate_read(ut_gip_01 + half, size - half, &uncompr2, &uncompr_len2, &(body.inflate), 2);
|
||||
EXPECT_EQ(ret, Z_STREAM_END);
|
||||
|
||||
char uncompr[1024] = {0};
|
||||
@@ -356,12 +356,12 @@ TEST(UI_TEST_INFLATE_GZIP, inflate_02)
|
||||
TEST(UI_TEST_DEFLATE_GZIP, deflate_01)
|
||||
{
|
||||
unsigned char *dest = NULL;
|
||||
struct data_t body;
|
||||
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 data_t));
|
||||
memset(&body, 0, sizeof(struct tfe_h2_payload));
|
||||
|
||||
ret = deflate_write(&(body.deflate), ut_ungip_01, size, buf, 2, 1);
|
||||
EXPECT_EQ(ret, Z_OK);
|
||||
@@ -371,7 +371,7 @@ TEST(UI_TEST_DEFLATE_GZIP, deflate_01)
|
||||
|
||||
char *uncompr = NULL;
|
||||
int uncompr_len = 0;
|
||||
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &(body.inflater), 2);
|
||||
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &(body.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);
|
||||
@@ -383,7 +383,7 @@ TEST(UI_TEST_DEFLATE_GZIP, deflate_01)
|
||||
|
||||
TEST(UI_TEST_DEFLATE_GZIP, deflate_02)
|
||||
{
|
||||
struct data_t body;
|
||||
struct tfe_h2_payload body;
|
||||
unsigned char *dest = NULL;
|
||||
int ret = 0, half = 0, dlen = 0;
|
||||
|
||||
@@ -392,7 +392,7 @@ TEST(UI_TEST_DEFLATE_GZIP, deflate_02)
|
||||
|
||||
struct evbuffer * buf = evbuffer_new();
|
||||
|
||||
memset(&body, 0, sizeof(struct data_t));
|
||||
memset(&body, 0, sizeof(struct tfe_h2_payload));
|
||||
|
||||
/* First frag */
|
||||
ret = deflate_write(&(body.deflate), ut_ungip_01, half, buf, 2, 0);
|
||||
@@ -411,7 +411,7 @@ TEST(UI_TEST_DEFLATE_GZIP, deflate_02)
|
||||
|
||||
char *uncompr = NULL;
|
||||
int uncompr_len = 0;
|
||||
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &(body.inflater), 2);
|
||||
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &(body.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);
|
||||
@@ -424,12 +424,12 @@ TEST(UI_TEST_DEFLATE_GZIP, deflate_02)
|
||||
TEST(UI_TEST_DEFLATE_BR, deflate_01)
|
||||
{
|
||||
unsigned char *dest = NULL;
|
||||
struct data_t body;
|
||||
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 data_t));
|
||||
memset(&body, 0, sizeof(struct tfe_h2_payload));
|
||||
|
||||
ret = deflate_write(&(body.deflate), ut_ungip_01, size, buf, HTTP2_CONTENT_ENCODING_BR, 1);
|
||||
EXPECT_EQ(ret, Z_OK);
|
||||
@@ -439,7 +439,7 @@ TEST(UI_TEST_DEFLATE_BR, deflate_01)
|
||||
|
||||
char *uncompr = NULL;
|
||||
int uncompr_len = 0;
|
||||
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &(body.inflater), HTTP2_CONTENT_ENCODING_BR);
|
||||
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &(body.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);
|
||||
@@ -451,7 +451,7 @@ TEST(UI_TEST_DEFLATE_BR, deflate_01)
|
||||
|
||||
TEST(UI_TEST_DEFLATE_BR, deflate_02)
|
||||
{
|
||||
struct data_t body;
|
||||
struct tfe_h2_payload body;
|
||||
unsigned char *dest = NULL;
|
||||
int ret = 0, half = 0, dlen = 0;
|
||||
|
||||
@@ -460,7 +460,7 @@ TEST(UI_TEST_DEFLATE_BR, deflate_02)
|
||||
|
||||
struct evbuffer * buf = evbuffer_new();
|
||||
|
||||
memset(&body, 0, sizeof(struct data_t));
|
||||
memset(&body, 0, sizeof(struct tfe_h2_payload));
|
||||
|
||||
/* First frag */
|
||||
ret = deflate_write(&(body.deflate), ut_ungip_01, half, buf, HTTP2_CONTENT_ENCODING_BR, 0);
|
||||
@@ -479,7 +479,7 @@ TEST(UI_TEST_DEFLATE_BR, deflate_02)
|
||||
|
||||
char *uncompr = NULL;
|
||||
int uncompr_len = 0;
|
||||
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &(body.inflater), HTTP2_CONTENT_ENCODING_BR);
|
||||
ret = inflate_read(dest, dlen, &uncompr, &uncompr_len, &(body.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);
|
||||
|
||||
Reference in New Issue
Block a user