2018-09-07 17:27:23 +08:00
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <tfe_http.h>
|
2018-09-12 15:29:35 +08:00
|
|
|
#include <tfe_plugin.h>
|
2018-09-07 17:27:23 +08:00
|
|
|
|
2018-09-12 15:29:35 +08:00
|
|
|
struct tfe_http_half * tfe_http_request_create(int major_version, int method, const char * uri, const char * host)
|
2018-09-07 17:27:23 +08:00
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 15:29:35 +08:00
|
|
|
struct tfe_http_half * tfe_http_response_create(int major_version, int resp_code)
|
2018-09-07 17:27:23 +08:00
|
|
|
{
|
2018-09-12 15:29:35 +08:00
|
|
|
return NULL;
|
2018-09-07 17:27:23 +08:00
|
|
|
}
|
|
|
|
|
|
2018-09-12 15:29:35 +08:00
|
|
|
struct ht_frame_session_ctx
|
2018-09-07 17:27:23 +08:00
|
|
|
{
|
2018-09-12 15:29:35 +08:00
|
|
|
void ** pmes;
|
|
|
|
|
unsigned int nr_pmes;
|
|
|
|
|
struct tfe_plugin * preempt_plugin;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ht_frame_session_ctx * http_frame_raise_session_begin(const struct tfe_stream * stream,
|
|
|
|
|
struct tfe_http_session * ht_session, unsigned int thread_id)
|
|
|
|
|
{
|
|
|
|
|
struct ht_frame_session_ctx * ss_ctx = ALLOC(struct ht_frame_session_ctx, 1);
|
|
|
|
|
ss_ctx->nr_pmes = tfe_plugin_total_counts();
|
|
|
|
|
ss_ctx->pmes = ALLOC(void *, ss_ctx->nr_pmes);
|
|
|
|
|
|
|
|
|
|
unsigned int __for_each_iterator = 0;
|
|
|
|
|
unsigned int __plugin_id = 0;
|
|
|
|
|
struct tfe_plugin * plugin_info_iter;
|
|
|
|
|
|
|
|
|
|
TFE_PLUGIN_FOREACH(plugin_info_iter, &__for_each_iterator)
|
|
|
|
|
{
|
|
|
|
|
if (plugin_info_iter->on_session_begin == NULL) continue;
|
|
|
|
|
plugin_info_iter->on_session_begin(stream, ht_session, thread_id, &ss_ctx->pmes[__plugin_id]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ss_ctx;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void http_frame_raise_session_end(struct ht_frame_session_ctx * ss_ctx, struct tfe_stream * stream,
|
|
|
|
|
struct tfe_http_session * ht_session, unsigned int thread_id)
|
|
|
|
|
{
|
|
|
|
|
unsigned int __for_each_iterator = 0;
|
|
|
|
|
unsigned int __plugin_id = 0;
|
|
|
|
|
struct tfe_plugin * plugin_info_iter;
|
|
|
|
|
|
|
|
|
|
TFE_PLUGIN_FOREACH(plugin_info_iter, &__for_each_iterator)
|
|
|
|
|
{
|
|
|
|
|
if (plugin_info_iter->on_session_end == NULL) continue;
|
|
|
|
|
plugin_info_iter->on_session_end(stream, ht_session, thread_id, &ss_ctx->pmes[__plugin_id]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free(ss_ctx->pmes);
|
|
|
|
|
free(ss_ctx);
|
2018-09-07 17:27:23 +08:00
|
|
|
}
|
|
|
|
|
|
2018-09-12 15:29:35 +08:00
|
|
|
void http_frame_raise_event(struct ht_frame_session_ctx * ht_frame,
|
|
|
|
|
const struct tfe_stream * stream, struct tfe_http_session * ht_session, enum tfe_http_event event,
|
|
|
|
|
const unsigned char * data, size_t datalen, unsigned int thread_id)
|
2018-09-07 17:27:23 +08:00
|
|
|
{
|
2018-09-12 15:29:35 +08:00
|
|
|
unsigned int __for_each_iterator = 0;
|
|
|
|
|
unsigned int __plugin_id = 0;
|
|
|
|
|
|
|
|
|
|
struct tfe_plugin * plugin_info_iter;
|
|
|
|
|
TFE_PLUGIN_FOREACH(plugin_info_iter, &__for_each_iterator)
|
|
|
|
|
{
|
|
|
|
|
if (plugin_info_iter->on_session_data == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
plugin_info_iter->on_session_data(stream, ht_session, event, data,
|
|
|
|
|
datalen, thread_id, &ht_frame->pmes[__plugin_id]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
2018-09-07 17:27:23 +08:00
|
|
|
}
|