变更HTTP业务层回调函数定义,增加session系列操作方法定义及虚接口实现。

* 不提供业务层针对单个数据包(段)的处理函数(返回值),业务层只能对单个session定义操作;
* 通过session的方法(函数)通知解析层对该session的处理方法。
This commit is contained in:
Lu Qiuwen
2018-09-12 15:29:35 +08:00
parent 74a4d38fba
commit 9e59110f8a
8 changed files with 447 additions and 165 deletions

View File

@@ -23,13 +23,12 @@ void http_plugin_deinit(struct tfe_proxy * proxy)
return;
}
struct http_session_private * hs_private_create( struct http_connection_private * hc_private,
struct http_session_private * hs_private_create(struct http_connection_private * hc_private,
struct http_half_private * hf_private_req, struct http_half_private * hf_private_resp)
{
struct http_session_private * __hs_private = ALLOC(struct http_session_private, 1);
/* HS-PUBLIC */
__hs_private->hs_public.major_version = 1;
__hs_private->hs_public.req = hf_private_req != NULL ? to_hf_public(hf_private_req) : NULL;
__hs_private->hs_public.resp = hf_private_req != NULL ? to_hf_public(hf_private_resp) : NULL;
__hs_private->hs_public.session_id = hc_private->session_id_counter++;
@@ -92,6 +91,16 @@ enum tfe_stream_action __http_connection_entry_on_request(const struct tfe_strea
__new_session:
hf_private_request = hf_private_create(TFE_HTTP_REQUEST, 1, 0);
hs_private = hs_private_create(hc_private, hf_private_request, NULL);
/* Call business plugin */
hs_private->ht_frame = http_frame_raise_session_begin(stream, &hs_private->hs_public, thread_id);
if(hs_private->ht_frame == NULL)
{
TFE_STREAM_LOG_ERROR(stream, "Failed at raising session begin event. ");
tfe_stream_detach(stream);
return ACTION_FORWARD_DATA;
}
TAILQ_INSERT_TAIL(&hc_private->hs_private_list, hs_private, next);
__parse:
@@ -113,10 +122,10 @@ __parse:
return ACTION_FORWARD_DATA;
}
assert(ret == 1);
if (hf_private_request->status_header == STATUS_COMPLETE)
{
printf("===== URI: %s\n", hf_private_request->hf_public.req_spec.uri);
http_frame_raise_event(hs_private->ht_frame, stream, &hs_private->hs_public,
EV_HTTP_REQ_HDR, NULL, 0, thread_id);
}
/* Touch a boundary, such as the end of HTTP headers, bodys, et al.
@@ -195,7 +204,6 @@ static struct tfe_plugin __http_plugin_info =
{
.symbol = "HTTP",
.type = TFE_PLUGIN_TYPE_PROTOCOL,
.proto = APP_PROTO_HTTP1,
.on_init = http_plugin_init,
.on_deinit = http_plugin_deinit,
.on_open = http_connection_entry_open,