summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/HTTP_Analyze.c9
-rw-r--r--src/HTTP_Message.c43
-rw-r--r--src/HTTP_Message.h4
-rw-r--r--src/HTTP_Message_Entry.c27
-rw-r--r--src/HTTP_Message_Header.c24
5 files changed, 53 insertions, 54 deletions
diff --git a/src/HTTP_Analyze.c b/src/HTTP_Analyze.c
index 3be9c8d..af07f72 100644
--- a/src/HTTP_Analyze.c
+++ b/src/HTTP_Analyze.c
@@ -688,13 +688,6 @@ void http_releaseHttpLinkNode(http_stream *a_http_stream,struct streaminfo *a_tc
dictator_free(thread_seq, cur_node->parser.batch_infor);
}
}
-
- if(cur_node->last_unzip_content.buf!=NULL)
- {
- dictator_free(thread_seq, cur_node->last_unzip_content.buf);
- cur_node->last_unzip_content.buf = NULL;
- cur_node->last_unzip_content.buflen = 0;
- }
if(cur_node->ungzip_handle!=NULL)
{
@@ -1140,7 +1133,7 @@ uchar http_analyseHttpConnection(http_stream* a_http_stream,struct streaminfo *a
#endif
*/
- //��Ϣ�����
+ //��Ϣ�����?
/*set mgs_status because cur_http_node maybe release*/
uchar mgs_status = HTTP_RETURN_GIVEME;
rec = http_findAndDoWithEntity(&mgs_status, cur_http_node, a_http_stream, a_tcp, thread_seq, a_packet);
diff --git a/src/HTTP_Message.c b/src/HTTP_Message.c
index a6822e7..41ce708 100644
--- a/src/HTTP_Message.c
+++ b/src/HTTP_Message.c
@@ -40,7 +40,7 @@ int is_absolute_uri(void* app_info)
int http_line2region(const char *line, uint32 line_len, char** region, uint32* region_len)
{
- /*line����ҵ��㣬��append,����lineǰ��Ŀո��Ѿ�ɾ����ֻ��Ҫɾ��: ֮��Ŀո�*/
+ /*line����ҵ��㣬��append,����lineǰ��Ŀո��Ѿ�ɾ����ֻ��Ҫɾ��: ֮��Ŀո�*/
uint32 del_data_len=0;
char* colon_pos = (char*)memchr(line, ':', line_len);
if(NULL==colon_pos) return -1;
@@ -52,7 +52,7 @@ int http_line2region(const char *line, uint32 line_len, char** region, uint32* r
int http_line2value(const char *line, uint32 line_len, char** value, uint32* value_len)
{
- /*line����ҵ��㣬��append,����lineǰ��Ŀո��Ѿ�ɾ����ֻ��Ҫɾ��: ֮��Ŀո�*/
+ /*line����ҵ��㣬��append,����lineǰ��Ŀո��Ѿ�ɾ����ֻ��Ҫɾ��: ֮��Ŀո�*/
uint32 vlen=0, sp_offset=0;
char* colon_pos = (char*)memchr(line, ':', line_len);
if(NULL==colon_pos) return -1;
@@ -371,6 +371,14 @@ int HTTP_INIT(void)
return -1;
}
+ int i=0;
+ g_http_prog_para.unzip_content=(fold_infor_t *)malloc(sizeof(fold_infor_t)*g_iThreadNum);
+ for(i=0; i<g_iThreadNum; i++)
+ {
+ g_http_prog_para.unzip_content[i].buflen=0;
+ g_http_prog_para.unzip_content[i].buf=(char *)calloc(1, HTTP_UNZIP_CONTENT_LEN);
+ }
+
/*MESA_proto*/
g_http_prog_para.proto_tag_id = project_producer_register("MESA_PROTO","struct",http_proto_tag_free);
@@ -561,6 +569,19 @@ void HTTP_DESTROY(void)
/*ungzip*/
docanalyze_destroy(g_http_prog_para.docanly_handler);
+
+ /*unzip_content*/
+ int i=0;
+ for(i=0; i<g_iThreadNum; i++)
+ {
+ if(g_http_prog_para.unzip_content[i].buf!=NULL)
+ {
+ free(g_http_prog_para.unzip_content[i].buf);
+ g_http_prog_para.unzip_content[i].buf = NULL;
+ }
+ }
+
+ free(g_http_prog_para.unzip_content);
}
void HTTP_PROT_FUNSTAT(unsigned long long protflag)
@@ -664,11 +685,11 @@ long long HTTP_FLAG_CHANGE(char* flag_str)
}
/**********************************************************
- * ���ܣ��ж���Ϣͷ�Ƿ������
- * buffer:��洢��������
- * data����ǰ���ݡ�
- * data_len:��ǰ���ݵij��ȡ�
- * proc_offset:��ǰ�����Ѵ������ݵ�ƫ������
+ * ���ܣ��ж���Ϣͷ�Ƿ������
+ * buffer:��洢��������
+ * data����ǰ���ݡ�
+ * data_len:��ǰ���ݵij��ȡ�
+ * proc_offset:��ǰ�����Ѵ������ݵ�ƫ������
return : GO_BACK OK ERROR
***********************************************************/
uchar http_judgeHeaderOver(http_parser_t *a_http, char *data, uint32 data_len, int thread_seq)
@@ -1040,10 +1061,10 @@ void http_saveToBuf(const char* curdata,uint32 cur_datalen,const char* p_end, ch
}
}
/**********************************************************
- * buffer:���ݴ洢��������
- * processed_offset����ǰ�����У��Ѵ������ݵ�ƫ����.
- * cur_data����ǰ���ݡ�
- * cur_data_len����ǰ���ݵij��ȡ�
+ * buffer:���ݴ洢��������
+ * processed_offset����ǰ�����У��Ѵ������ݵ�ƫ����.
+ * cur_data����ǰ���ݡ�
+ * cur_data_len����ǰ���ݵij��ȡ�
***********************************************************/
uchar http_positioningACompleteLine(char del_space, http_parser_t *cur_http_node, struct streaminfo *a_tcp, int thread_seq)
{
diff --git a/src/HTTP_Message.h b/src/HTTP_Message.h
index ca901ab..03234ec 100644
--- a/src/HTTP_Message.h
+++ b/src/HTTP_Message.h
@@ -104,6 +104,7 @@
#define LINE_FLAG_LF 0x02
#define LINE_FLAG_CRLF 0x03
+#define HTTP_UNZIP_CONTENT_LEN 16*1024
typedef enum
{
@@ -168,8 +169,6 @@ typedef struct _http_parser_t
char endline_flag; //complete line flag: \r\n, \r, \n.
uint8 mgs_status; //return state
uint8 header_span_flag; //see define
-
- fold_infor_t last_unzip_content;
#if HTTP_PROXY
uchar proxy_flag; //DIR_C2S, DIR_S2C,DIR_DOUBLE
@@ -227,6 +226,7 @@ typedef struct _http_prog_runtime_parameter_t
int capfile_project_id;
#endif
int proto_tag_id ;
+ fold_infor_t *unzip_content;
}http_prog_runtime_parameter_t;
struct http_proto_tag_t
diff --git a/src/HTTP_Message_Entry.c b/src/HTTP_Message_Entry.c
index 1c51735..3e8b7f4 100644
--- a/src/HTTP_Message_Entry.c
+++ b/src/HTTP_Message_Entry.c
@@ -69,33 +69,32 @@ void http_doWithGzipData(http_parser_t *cur_http_node, struct streaminfo *a_tcp,
return ;
}
- cur_http_node->last_unzip_content.buflen=0;
- if(cur_http_node->last_unzip_content.buf!=NULL)
- {
- dictator_free(thread_seq, cur_http_node->last_unzip_content.buf);
- cur_http_node->last_unzip_content.buf=NULL;
- }
-
ret=docanalyze_parsestream(cur_http_node->ungzip_handle,
(const char*)cur_http_node->session.buf,
cur_http_node->session.buflen,
result_array);
if(ret==DOC_PRO_OK)
{
+ fold_infor_t *unzip_content=&(g_http_prog_para.unzip_content[thread_seq]);
+ unzip_content->buflen=0;
+
int k=0;
for (k=0; k < result_array->result_num; k++)
{
- cur_http_node->last_unzip_content.buf=(char*)dictator_realloc(thread_seq, cur_http_node->last_unzip_content.buf, cur_http_node->last_unzip_content.buflen+result_array->result_buff[k].size);
- memcpy(cur_http_node->last_unzip_content.buf+cur_http_node->last_unzip_content.buflen,
- result_array->result_buff[k].presult,
- result_array->result_buff[k].size);
- cur_http_node->last_unzip_content.buflen += result_array->result_buff[k].size;
+ int min_len=MIN(result_array->result_buff[k].size, HTTP_UNZIP_CONTENT_LEN-unzip_content->buflen);
+ if(min_len<=0)
+ {
+ break;
+ }
+
+ memcpy(unzip_content->buf+unzip_content->buflen, result_array->result_buff[k].presult, min_len);
+ unzip_content->buflen+=min_len;
}
FLAG_SET(cur_http_node->flag, HTTP_FLAG_BATCH_CALLBACK);
- cur_http_node->session.buf=cur_http_node->last_unzip_content.buf;
- cur_http_node->session.buflen=cur_http_node->last_unzip_content.buflen;
+ cur_http_node->session.buf=unzip_content->buf;
+ cur_http_node->session.buflen=unzip_content->buflen;
http_callPlugin(cur_http_node, a_tcp, thread_seq, a_packet);
cur_http_node->session.buf=NULL;
cur_http_node->session.buflen=0;
diff --git a/src/HTTP_Message_Header.c b/src/HTTP_Message_Header.c
index 512ef04..bdc30e0 100644
--- a/src/HTTP_Message_Header.c
+++ b/src/HTTP_Message_Header.c
@@ -42,13 +42,6 @@ void http_initHttpCommonInfor( http_parser_t *a_http, int thread_seq)
a_http->packet_entity_len = 0;
a_http->acc_cont_length = 0;
- if(a_http->last_unzip_content.buf!=NULL)
- {
- dictator_free(thread_seq, a_http->last_unzip_content.buf);
- a_http->last_unzip_content.buf = NULL;
- a_http->last_unzip_content.buflen = 0;
- }
-
if(a_http->ungzip_handle!=NULL)
{
docanalyze_endstream(a_http->ungzip_handle);
@@ -69,7 +62,7 @@ void http_initHttpCommonInfor( http_parser_t *a_http, int thread_seq)
}
/**********************************************************
- * ���ܣ���Ӧ��Ϣ����ʱ�������Ӧ��������Ϣ��Ϣ��
+ * ���ܣ���Ӧ��Ϣ����ʱ�������Ӧ���������?��Ϣ��
* a_http:��ǰ�ڵ㡣
**********************************************************/
void http_resetResponseSpace(http_parser_t *a_http, int thread_seq)
@@ -135,7 +128,7 @@ void http_initHttpCommonInfor( http_parser_t *a_http, int thread_seq)
/**********************************************************
* ���ܣ�����HTTP����������
* a_http����ǰ��������
- * curdir:tcp���ݰ��ķ��򣬱�����˫�����
+ * curdir:tcp���ݰ��ķ��򣬱�����˫�����?
* dir����ǰ���ķ���
*********************************************************/
void http_buildHttpInforLink(http_stream *a_http_stream, int thread_seq, struct streaminfo *a_tcp, void *a_packet)
@@ -217,7 +210,7 @@ void http_initHttpCommonInfor( http_parser_t *a_http, int thread_seq)
/**********************************************************
* ���ܣ���ʼ��HTTP���ӡ�
- * curdir:tcp���ݰ��ķ��򣬱�����˫�����
+ * curdir:tcp���ݰ��ķ��򣬱�����˫�����?
* dir����ǰ���ķ���
* pme������������
***********************************************************/
@@ -324,13 +317,6 @@ static void http_reseaseHttpInforList(http_parser_t**a_http, UINT16 uncomplete_c
{
stat_field_operation(g_http_prog_para.stat_handler, g_http_prog_para.stat_field[HTTP_STAT_RELEASE], FS_OP_TYPE_ADD, 1);
}
-
- if(cur_http_node->last_unzip_content.buf!=NULL)
- {
- dictator_free(thread_seq, cur_http_node->last_unzip_content.buf);
- cur_http_node->last_unzip_content.buf = NULL;
- cur_http_node->last_unzip_content.buflen = 0;
- }
if(cur_http_node->ungzip_handle!=NULL)
{
@@ -688,7 +674,7 @@ uchar http_processHttpProxy(http_parser_t *a_http, http_stream *a_http_stream, s
pProxydetail->uiApendLen = a_http->url_buflen;
}
- //���������������Ϣ��
+ //����������������?��
/*user and passwd in C2S*/
if(a_http->parser.curdir==DIR_C2S)
{
@@ -752,7 +738,7 @@ uchar http_analyseHttpProxy(http_parser_t *a_http, http_stream *a_http_stream,
a_http_stream->p_stream_proxy->type = STREAM_TYPE_HTTP_PROXY;
struct proxydetail* pProxydetail = (struct proxydetail *)(a_http_stream->p_stream_proxy->pdetail);
- //������״ν���
+ //������״ν���?
if(pProxydetail==NULL)
{
pProxydetail=(struct proxydetail*)dictator_malloc(thread_seq,sizeof(struct proxydetail));