完成HTTP请求侧解析调试,可以解析请求的URL。
* 增加插件管理功能(简单实现),可以调用解析层插件; * 调整HTTP请求侧解析回调函数实现; * 增加hexdump工具函数;
This commit is contained in:
@@ -68,6 +68,8 @@ enum tfe_stream_action __http_connection_entry_on_request(const struct tfe_strea
|
||||
{
|
||||
struct http_session_private * hs_private = TAILQ_LAST(&hc_private->hs_private_list, hs_private_list);
|
||||
struct http_half_private * hf_private_request = NULL;
|
||||
|
||||
/* tfe_hexdump(stderr, __FUNCTION__, data, (unsigned int)len); */
|
||||
int ret = 0;
|
||||
|
||||
/* There is no available in session list,
|
||||
@@ -80,7 +82,7 @@ enum tfe_stream_action __http_connection_entry_on_request(const struct tfe_strea
|
||||
/* The last request is finished, we need to create a new session,
|
||||
* or proceed parse content for last request */
|
||||
hf_private_request = to_hf_request_private(hs_private);
|
||||
if (hf_private_request->finished)
|
||||
if (hf_private_request->status_message == STATUS_COMPLETE)
|
||||
{
|
||||
goto __new_session;
|
||||
}
|
||||
@@ -112,11 +114,18 @@ __parse:
|
||||
}
|
||||
|
||||
assert(ret == 1);
|
||||
if (hf_private_request->status_header == STATUS_COMPLETE)
|
||||
{
|
||||
printf("===== URI: %s\n", hf_private_request->hf_public.req_spec.uri);
|
||||
}
|
||||
|
||||
/* Touch a boundary, such as the end of HTTP headers, bodys, et al.
|
||||
* need to call user's cb */
|
||||
size_t __forward_bytes = hf_private_request->parse_cursor;
|
||||
tfe_stream_action_set_opt(stream, ACTION_OPT_FOWARD_BYTES, &__forward_bytes, sizeof(__forward_bytes));
|
||||
|
||||
/* Clear the parser cursor */
|
||||
hf_private_request->parse_cursor = 0;
|
||||
return ACTION_FORWARD_DATA;
|
||||
}
|
||||
|
||||
@@ -164,6 +173,7 @@ enum tfe_stream_action http_connection_entry_data(const struct tfe_stream * stre
|
||||
* It may be failed because other plugin preempted before us */
|
||||
ret = tfe_stream_preempt(stream);
|
||||
if (ret != 0) goto __detach;
|
||||
ht_conn->is_preempted = 1;
|
||||
}
|
||||
|
||||
/* This stream has been preempt, this plugin try to parse it */
|
||||
@@ -182,15 +192,15 @@ void http_connection_entry_close(const struct tfe_stream * stream, unsigned int
|
||||
}
|
||||
|
||||
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,
|
||||
.on_data = http_connection_entry_data,
|
||||
.on_close = http_connection_entry_close
|
||||
};
|
||||
{
|
||||
.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,
|
||||
.on_data = http_connection_entry_data,
|
||||
.on_close = http_connection_entry_close
|
||||
};
|
||||
|
||||
TFE_PLUGIN_REGISTER(HTTP, __http_plugin_info)
|
||||
|
||||
Reference in New Issue
Block a user