修正HTTP解析层处理HTTP-Header的错误流程

* 原流程在解析同一个Field-Value对时,无法正确处理Header多次调用拼成完整字符串的情况,现修正;
* 原流程在处理Field-Value底层Buffer时计算长度有误,导致清空buffer时剩余最后的'\0',现修正。
This commit is contained in:
Lu Qiuwen
2018-09-18 18:50:25 +08:00
parent 8dee003483
commit 9ccc3d329e
3 changed files with 38 additions and 22 deletions

View File

@@ -67,6 +67,7 @@ enum tfe_stream_action __http_connection_entry_on_request(const struct tfe_strea
/* HTTP Request and Session */
hf_private_request = hf_private_create(TFE_HTTP_REQUEST, 1, 0);
hs_private = hs_private_create(hc_private, hf_private_request, NULL);
hf_private_set_session(hf_private_request, hs_private);
/* Closure, catch stream, session and thread_id */
struct user_event_dispatch_closure * __closure = ALLOC(struct user_event_dispatch_closure, 1);
@@ -139,13 +140,13 @@ enum tfe_stream_action __http_connection_entry_on_response(const struct tfe_stre
int __http_connection_identify(const struct tfe_stream * stream,
struct http_connection_private * ht_conn, const unsigned char * data, size_t len)
{
struct http_half_private * hf_private = hf_private_create(TFE_HTTP_RESPONSE, 1, 0);
struct http_half_private * hf_private = hf_private_create(TFE_HTTP_REQUEST, 1, 0);
int ret = hf_private_parse(hf_private, data, len);
hf_private_destory(hf_private);
return ret;
}
#define HTTP_INDENTIFY_LENGTH 8
#define HTTP_INDENTIFY_LENGTH 4
enum tfe_stream_action http_connection_entry_data(const struct tfe_stream * stream, unsigned int thread_id,
enum tfe_conn_dir dir, const unsigned char * data, size_t len, void ** pme)
@@ -159,12 +160,7 @@ enum tfe_stream_action http_connection_entry_data(const struct tfe_stream * stre
goto __detach;
/* Protocol Identification, we need 8 bytes at least to tell it is HTTP or not */
if (len < HTTP_INDENTIFY_LENGTH)
{
static const unsigned int __defer_bytes = HTTP_INDENTIFY_LENGTH;
tfe_stream_action_set_opt(stream, ACTION_OPT_DEFER_BYTES, (void *) &__defer_bytes, sizeof(__defer_bytes));
return ACTION_DEFER_DATA;
}
if (len < HTTP_INDENTIFY_LENGTH) goto __detach;
/* Now, we want to identify this stream */
int ret = __http_connection_identify(stream, ht_conn, data, len);