summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlishu <[email protected]>2021-06-18 18:44:46 +0800
committerlishu <[email protected]>2021-06-18 18:44:46 +0800
commitdd10be9f413e6a660d3a43ebd2d8ea566d8e94ee (patch)
tree3d46f8673dc9bf51525584805349e5a4febab514 /src
parent1a428ed842873d2a80ea09443bd17e6a316da51f (diff)
处理s2c单向流下,响应体对应的是HEAD方法。
Diffstat (limited to 'src')
-rw-r--r--src/HTTP_Analyze.c3
-rw-r--r--src/HTTP_Message.c2
-rw-r--r--src/HTTP_Message.h1
-rw-r--r--src/HTTP_Message_Entry.c26
-rw-r--r--src/HTTP_Message_Header.c4
-rw-r--r--src/http_update.txt3
6 files changed, 34 insertions, 5 deletions
diff --git a/src/HTTP_Analyze.c b/src/HTTP_Analyze.c
index 8c22e7e..a585bb2 100644
--- a/src/HTTP_Analyze.c
+++ b/src/HTTP_Analyze.c
@@ -47,7 +47,7 @@ extern "C"
http_prog_runtime_parameter_t g_http_prog_para;
int G_HTTP_H_VERSION_4_20191205 = 0;
-int G_HTTP_VERSION_4_20210521 = 0;
+int G_HTTP_VERSION_4_20210618 = 0;
void history()
{
//2014-12-09 V3.0 new documentAnalyze lib ; http.h add and delete ;
@@ -129,6 +129,7 @@ void history()
//2020-06-12 V4.0 //set pbuf=null when resethttpstream
//2020-07-22 V4.0 //range Invalid
//2021-05-21 V4.0 //URI do not start with '/' and http_host_parser
+ //2021-06-18 V4.0 //fix:http head when only one-way of S2C
}
diff --git a/src/HTTP_Message.c b/src/HTTP_Message.c
index e0325a4..22d3cff 100644
--- a/src/HTTP_Message.c
+++ b/src/HTTP_Message.c
@@ -276,6 +276,8 @@ int http_readMainConf(const char* filename)
MESA_load_profile_short_def(filename, "FUNCTION", "callback_mode", (short*)&g_http_prog_para.callback_mode,0);
MESA_load_profile_short_def(filename, "FUNCTION", "batch_field_maxnum", (short*)&g_http_prog_para.batch_field_maxnum,64);
MESA_load_profile_string_def(filename, "FUNCTION", "stat_file", g_http_prog_para.http_stat_filename, sizeof(g_http_prog_para.http_stat_filename),"./log/http/http_stat.log");
+ MESA_load_profile_short_def(filename, "FUNCTION", "s2c_head_check_switch", (short*)&g_http_prog_para.s2c_head_check_switch,0);
+
return 0;
}
diff --git a/src/HTTP_Message.h b/src/HTTP_Message.h
index ee53695..a1107e3 100644
--- a/src/HTTP_Message.h
+++ b/src/HTTP_Message.h
@@ -207,6 +207,7 @@ typedef struct _http_prog_runtime_parameter_t
uint16 callback_mode;
uint16 batch_field_maxnum;
uint16 proxy_switch;
+ uint16 s2c_head_check_switch;
uchar need_http_state;
uchar not_proc;
diff --git a/src/HTTP_Message_Entry.c b/src/HTTP_Message_Entry.c
index 032db19..c7329c9 100644
--- a/src/HTTP_Message_Entry.c
+++ b/src/HTTP_Message_Entry.c
@@ -463,7 +463,7 @@ uchar http_doWithEntity(http_parser_t *cur_http_node, http_stream *a_http_stream
else if(a_http_stream->is_proxy)
{
rec = http_doWithProxyData(cur_http_node, a_http_stream,a_tcp,thread_seq, a_packet);
- }
+ }
else
{
rec = http_doWithDefaultData(cur_http_node, a_http_stream, a_tcp,thread_seq, a_packet);
@@ -548,7 +548,7 @@ uchar http_judgeResponseEntityPresent(http_parser_t *a_http, http_stream* a_htt
http_callPlugin(a_http, a_tcp, thread_seq, a_packet);
}
return ERROR;
- }
+ }
return OK;
}/*http_judgeResponseEntityPresent*/
@@ -566,6 +566,23 @@ uchar http_judgeEntityPresent(http_parser_t *cur_http_node, http_stream *a_http_
return rec;
}
+void http_s2cHead(http_parser_t *cur_http_node, http_stream *a_http_stream, struct streaminfo *a_tcp, int thread_seq, void *a_packet)
+{
+ struct tcpdetail *tcp_detail = (struct tcpdetail*)a_tcp->pdetail;
+ uint32* offset = &(cur_http_node->processed_offset);
+ char* cur_data = (char*)(tcp_detail->pdata);
+ uchar method = HTTP_METHOD_UNKNOWN;
+ uint32 len = tcp_detail->datalen - *offset;
+
+ if(len>HTTP_START_FLAGS_LEN)
+ {
+ if(OK==http_judgeHttpMethod(&method, cur_data+*offset, a_http_stream->res_req))
+ {
+ cur_http_node->packet_entity_len = 0;
+ }
+ }
+}
+
uchar http_findAndDoWithEntity(uchar* msg_status, http_parser_t *a_http, http_stream* a_http_stream, struct streaminfo *a_tcp, int thread_seq, void *a_packet)
{
uchar rec = OK;
@@ -595,6 +612,11 @@ uchar http_findAndDoWithEntity(uchar* msg_status, http_parser_t *a_http, http_st
if(a_http->parser.http_state==HTTP_DATA)
{
+ /*20210618 S2C but maybe head*/
+ if (g_http_prog_para.s2c_head_check_switch && DIR_S2C==a_http_stream->dir && 200==(a_http->parser.res_code) && 0!=a_http->parser.cont_length)
+ {
+ http_s2cHead(a_http, a_http_stream, a_tcp, thread_seq, a_packet);
+ }
rec = http_doWithEntity(a_http, a_http_stream, a_tcp, thread_seq, a_packet);
http_updatePktOffset(a_http, a_http_stream, a_tcp);
*msg_status = a_http->mgs_status;
diff --git a/src/HTTP_Message_Header.c b/src/HTTP_Message_Header.c
index 8d1630d..8345b14 100644
--- a/src/HTTP_Message_Header.c
+++ b/src/HTTP_Message_Header.c
@@ -238,14 +238,14 @@ void http_initHttpConnection(http_stream *a_http_stream, int thread_seq, struct
{
if(a_tcp->curdir==DIR_C2S)
{
- if(DIR_DOUBLE!=a_tcp->dir && g_http_prog_para.singleway_seq >0 && a_http_stream->create_infor_num > g_http_prog_para.singleway_seq)
+ if(DIR_DOUBLE!=a_tcp->dir && (g_http_prog_para.singleway_seq ==0 || (g_http_prog_para.singleway_seq >0 && a_http_stream->create_infor_num > g_http_prog_para.singleway_seq)))
{
a_http_stream->dir = DIR_C2S;
}
}
else
{
- if(DIR_DOUBLE!=a_tcp->dir && g_http_prog_para.singleway_seq >0 && a_http_stream->create_infor_num > g_http_prog_para.singleway_seq)
+ if(DIR_DOUBLE!=a_tcp->dir && (g_http_prog_para.singleway_seq ==0 || (g_http_prog_para.singleway_seq >0 && a_http_stream->create_infor_num > g_http_prog_para.singleway_seq)))
{
a_http_stream->dir = DIR_S2C;
}
diff --git a/src/http_update.txt b/src/http_update.txt
index 1755dc8..899a75b 100644
--- a/src/http_update.txt
+++ b/src/http_update.txt
@@ -1,3 +1,6 @@
+20210618
+֧�ּ��s2c��������������Ƿ���HEAD
+***************************************************************
20200109
1. ����Э��ʶ���ǩ�����MESA_proto.soͳ��Э������
***************************************************************