完成HTTP解析请求侧解析基本流程

* 集成HTTP Parser,解析HTTP请求侧数据;
* 增加tfe_http.h中请求方法、应答状态的常量定义
* 变更tfe_http.h中HTTP头部标准定义,去掉非头部字段,增加TFE前缀避免冲突。
This commit is contained in:
Lu Qiuwen
2018-09-06 10:12:08 +08:00
parent 89b79eab60
commit e31ecbb8db
8 changed files with 723 additions and 120 deletions

View File

@@ -0,0 +1,82 @@
#pragma once
extern "C"
{
#include <sys/queue.h>
}
#include <tfe_http.h>
#include <http_parser.h>
struct http_plugin
{
};
TAILQ_HEAD(hs_private_list, http_session_private);
struct http_session_private
{
struct tfe_http_session hs_public;
TAILQ_ENTRY(http_session_private) next;
struct http_connection_private * hc_private;
};
struct http_connection_private
{
/* ADDRESS */
struct tfe_stream_addr * layer_addr;
/* SESSION LIST, REQUEST-RESPONSE PAIRS */
struct hs_private_list hs_private_list;
/* IS PREEMPTED */
unsigned int is_preempted;
/* SESSION ID COUNTER */
unsigned int session_id_counter;
};
struct http_half_private
{
/* PUBLIC STRUCTURE */
struct tfe_http_half hf_public;
/* SESSION OF THIS REQUEST/RESPONSE */
struct http_session_private * session;
/* HTTP PARSER */
struct http_parser * parse_object;
/* HTTP PARSER SETTING */
struct http_parser_settings * parse_settings;
/* CURSOR RELATED TO DELAYED DATA */
size_t parse_cursor;
/* HTTP PARSER'S ERRNO */
enum http_errno parse_errno;
/* UNDERLAY BUFFER */
int method_or_status;
short major;
short minor;
struct evbuffer * evbuf_uri;
char * underlay_uri;
char * underlay_url;
struct evbuffer * evbuf_header_field;
struct evbuffer * evbuf_header_value;
struct evbuffer * evbuf_body;
/* STATUS */
bool finished;
};
static inline struct http_half_private * to_hf_request_private(struct http_session_private * hs_private)
{
struct tfe_http_half * hf_public = hs_private->hs_public.req;
return container_of(hf_public, struct http_half_private, hf_public);
}
static inline struct http_half_private * to_hf_response_private(struct http_session_private * hs_private)
{
struct tfe_http_half * hf_public = hs_private->hs_public.resp;
return container_of(hf_public, struct http_half_private, hf_public);
}
static inline struct tfe_http_half * to_hf_public(struct http_half_private * hf_private)
{
return &hf_private->hf_public;
}