增加简单的HTTP协议插件管理层,基本联通HTTP解析层与业务层插件。
This commit is contained in:
@@ -6,6 +6,7 @@ extern "C"
|
||||
}
|
||||
|
||||
#include <tfe_http.h>
|
||||
#include <http_half.h>
|
||||
#include <http_parser.h>
|
||||
|
||||
struct http_plugin
|
||||
@@ -13,12 +14,22 @@ struct http_plugin
|
||||
};
|
||||
|
||||
TAILQ_HEAD(hs_private_list, http_session_private);
|
||||
|
||||
struct http_plugin_status
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
struct http_session_private
|
||||
{
|
||||
/* PUBLIC */
|
||||
struct tfe_http_session hs_public;
|
||||
/* TAILQ POINTER */
|
||||
TAILQ_ENTRY(http_session_private) next;
|
||||
/* REF, HTTP CONNECTION */
|
||||
struct http_connection_private * hc_private;
|
||||
struct ht_frame_session_ctx * ht_frame;
|
||||
/* HTTP FRAME CTX */
|
||||
struct http_frame_session_ctx * ht_frame;
|
||||
};
|
||||
|
||||
struct http_connection_private
|
||||
@@ -35,79 +46,46 @@ struct http_connection_private
|
||||
unsigned int session_id_counter;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(http_header_private_list, http_header_private);
|
||||
struct http_header_private
|
||||
{
|
||||
TAILQ_ENTRY(http_header_private) next;
|
||||
struct http_field_name * field;
|
||||
char * value;
|
||||
};
|
||||
|
||||
enum hf_private_status
|
||||
{
|
||||
STATUS_INIT,
|
||||
STATUS_READING,
|
||||
STATUS_COMPLETE,
|
||||
};
|
||||
|
||||
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;
|
||||
/* HEADER K-V */
|
||||
struct http_header_private_list header_list;
|
||||
|
||||
/* 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;
|
||||
|
||||
enum hf_private_status status_header;
|
||||
enum hf_private_status status_body;
|
||||
enum hf_private_status status_message;
|
||||
};
|
||||
|
||||
static inline struct http_half_private * to_hf_request_private(struct http_session_private * hs_private)
|
||||
{
|
||||
if(hs_private == NULL) return NULL;
|
||||
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)
|
||||
{
|
||||
if(hs_private == NULL) return NULL;
|
||||
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)
|
||||
{
|
||||
if(hf_private == NULL) return NULL;
|
||||
return &hf_private->hf_public;
|
||||
}
|
||||
|
||||
static inline struct http_half_private * to_hf_private(struct tfe_http_half * hf_public)
|
||||
{
|
||||
if(hf_public == NULL) return NULL;
|
||||
return container_of(hf_public, struct http_half_private, hf_public);
|
||||
}
|
||||
|
||||
static inline const struct http_half_private * to_hf_private(const struct tfe_http_half * hf_public)
|
||||
{
|
||||
if(hf_public == NULL) return NULL;
|
||||
return container_of(hf_public, struct http_half_private, hf_public);
|
||||
}
|
||||
|
||||
static inline const struct tfe_http_session * to_hs_public(const struct http_session_private * hs_private)
|
||||
{
|
||||
if (hs_private == NULL) return NULL;
|
||||
return &hs_private->hs_public;
|
||||
}
|
||||
|
||||
static inline struct http_session_private * to_hs_private(struct tfe_http_session * hs_public)
|
||||
{
|
||||
if (hs_public == NULL) return NULL;
|
||||
return container_of(hs_public, struct http_session_private, hs_public);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user