增加标准HTTP头部定义转字符串的工具函数,修正pango-http插件在初始化时没有设置PME的错误。
This commit is contained in:
@@ -201,42 +201,10 @@ typedef void (http_session_data_cb)(const struct tfe_stream * stream,
|
|||||||
typedef void (http_session_end_cb)(const struct tfe_stream * stream,
|
typedef void (http_session_end_cb)(const struct tfe_stream * stream,
|
||||||
const struct tfe_http_session * session, unsigned int thread_id, void ** pme);
|
const struct tfe_http_session * session, unsigned int thread_id, void ** pme);
|
||||||
|
|
||||||
static inline struct http_field_name * http_field_name_duplicate(const struct http_field_name * orig)
|
struct http_field_name * http_field_name_duplicate(const struct http_field_name * orig);
|
||||||
{
|
int http_field_name_compare(const struct http_field_name * lvalue, const struct http_field_name * rvalue);
|
||||||
struct http_field_name * __duplicated = ALLOC(struct http_field_name, 1);
|
const char * http_field_to_string(const struct http_field_name * field);
|
||||||
assert(__duplicated != NULL);
|
void http_field_destory(struct http_field_name *);
|
||||||
|
|
||||||
if (orig->field_id == TFE_HTTP_UNKNOWN_FIELD)
|
|
||||||
{
|
|
||||||
__duplicated->field_id = TFE_HTTP_UNKNOWN_FIELD;
|
|
||||||
__duplicated->field_name = tfe_strdup(orig->field_name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
__duplicated->field_id = orig->field_id;
|
|
||||||
__duplicated->field_name = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return __duplicated;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int http_field_name_compare(const struct http_field_name * lvalue,
|
|
||||||
const struct http_field_name * rvalue)
|
|
||||||
{
|
|
||||||
if (lvalue->field_id != rvalue->field_id)
|
|
||||||
{
|
|
||||||
return (lvalue->field_id - rvalue->field_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* unknown field, compare field_name in string */
|
|
||||||
if (lvalue->field_id == TFE_HTTP_UNKNOWN_FIELD)
|
|
||||||
{
|
|
||||||
return strcasecmp(lvalue->field_name, rvalue->field_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* field_id is equal, but not unknown, hit */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline const char * tfe_http_field_read(const struct tfe_http_half * half,
|
static inline const char * tfe_http_field_read(const struct tfe_http_half * half,
|
||||||
const struct http_field_name * name)
|
const struct http_field_name * name)
|
||||||
|
|||||||
@@ -14,6 +14,87 @@ struct tfe_http_half * tfe_http_response_create(int major_version, int resp_code
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char * __str_std_header_field_map[] =
|
||||||
|
{
|
||||||
|
[TFE_HTTP_UNKNOWN_FIELD] = NULL,
|
||||||
|
[TFE_HTTP_HOST] = "Host",
|
||||||
|
[TFE_HTTP_REFERER] = "Referer",
|
||||||
|
[TFE_HTTP_USER_AGENT] = "User-Agent",
|
||||||
|
[TFE_HTTP_COOKIE] = "Cookie",
|
||||||
|
[TFE_HTTP_PROXY_AUTHORIZATION] = "Proxy-Authorization",
|
||||||
|
[TFE_HTTP_AUTHORIZATION] = "Authorization",
|
||||||
|
[TFE_HTTP_LOCATION] = "Location",
|
||||||
|
[TFE_HTTP_SERVER] = "Server",
|
||||||
|
[TFE_HTTP_ETAG] = "Etag",
|
||||||
|
[TFE_HTTP_DATE] = "Date",
|
||||||
|
[TFE_HTTP_TRAILER] = "Trailer",
|
||||||
|
[TFE_HTTP_TRANSFER_ENCODING] = "Transfer-Encoding",
|
||||||
|
[TFE_HTTP_VIA] = "Via",
|
||||||
|
[TFE_HTTP_PRAGMA] = "Pragma",
|
||||||
|
[TFE_HTTP_CONNECTION] = "Connection",
|
||||||
|
[TFE_HTTP_CONT_ENCODING] = "Content-Encoding",
|
||||||
|
[TFE_HTTP_CONT_LANGUAGE] = "Content-Language",
|
||||||
|
[TFE_HTTP_CONT_LOCATION] = "Content-Location",
|
||||||
|
[TFE_HTTP_CONT_RANGE] = "Content-Range",
|
||||||
|
[TFE_HTTP_CONT_LENGTH] = "Content-Length",
|
||||||
|
[TFE_HTTP_CONT_TYPE] = "Content-Type",
|
||||||
|
[TFE_HTTP_CONT_DISPOSITION] = "Content-Disposition",
|
||||||
|
[TFE_HTTP_EXPIRES] = "Expires",
|
||||||
|
[TFE_HTTP_ACCEPT_ENCODING] = "Accept-Encoding"
|
||||||
|
};
|
||||||
|
|
||||||
|
struct http_field_name * http_field_name_duplicate(const struct http_field_name * orig)
|
||||||
|
{
|
||||||
|
struct http_field_name * __duplicated = ALLOC(struct http_field_name, 1);
|
||||||
|
assert(__duplicated != NULL);
|
||||||
|
|
||||||
|
if (orig->field_id == TFE_HTTP_UNKNOWN_FIELD)
|
||||||
|
{
|
||||||
|
__duplicated->field_id = TFE_HTTP_UNKNOWN_FIELD;
|
||||||
|
__duplicated->field_name = tfe_strdup(orig->field_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__duplicated->field_id = orig->field_id;
|
||||||
|
__duplicated->field_name = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return __duplicated;
|
||||||
|
}
|
||||||
|
|
||||||
|
int http_field_name_compare(const struct http_field_name * lvalue, const struct http_field_name * rvalue)
|
||||||
|
{
|
||||||
|
if (lvalue->field_id != rvalue->field_id)
|
||||||
|
{
|
||||||
|
return (lvalue->field_id - rvalue->field_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* unknown field, compare field_name in string */
|
||||||
|
if (lvalue->field_id == TFE_HTTP_UNKNOWN_FIELD)
|
||||||
|
{
|
||||||
|
return strcasecmp(lvalue->field_name, rvalue->field_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* field_id is equal, but not unknown, hit */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct http_field_name * http_field_construct_from_string(const char * str_field)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * http_field_to_string(const struct http_field_name * field)
|
||||||
|
{
|
||||||
|
if (field->field_id != TFE_HTTP_UNKNOWN_FIELD) return __str_std_header_field_map[field->field_id];
|
||||||
|
return field->field_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void http_field_destory(struct http_field_name * field)
|
||||||
|
{
|
||||||
|
free(field);
|
||||||
|
}
|
||||||
|
|
||||||
struct http_frame_session_ctx
|
struct http_frame_session_ctx
|
||||||
{
|
{
|
||||||
struct http_frame_plugin_status * plugin_status;
|
struct http_frame_plugin_status * plugin_status;
|
||||||
|
|||||||
@@ -808,8 +808,11 @@ enum pangu_action http_scan(const struct tfe_http_session * session, enum tfe_ht
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char * str_field_name = http_field_to_string(&field_name);
|
||||||
scan_ret=Maat_set_scan_status(g_pangu_rt->maat, &(ctx->mid), MAAT_SET_SCAN_DISTRICT,
|
scan_ret=Maat_set_scan_status(g_pangu_rt->maat, &(ctx->mid), MAAT_SET_SCAN_DISTRICT,
|
||||||
field_name.field_name,strlen(field_name.field_name));
|
str_field_name,strlen(str_field_name));
|
||||||
|
|
||||||
assert(scan_ret==0);
|
assert(scan_ret==0);
|
||||||
scan_ret=Maat_full_scan_string(g_pangu_rt->maat, table_id,
|
scan_ret=Maat_full_scan_string(g_pangu_rt->maat, table_id,
|
||||||
CHARSET_UTF8, field_val, strlen(field_val),
|
CHARSET_UTF8, field_val, strlen(field_val),
|
||||||
@@ -886,6 +889,8 @@ void pangu_on_http_begin(const struct tfe_stream * stream,
|
|||||||
{
|
{
|
||||||
tfe_http_session_detach(session);
|
tfe_http_session_detach(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*pme=ctx;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user