summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author李舒 <[email protected]>2021-06-21 03:39:39 +0000
committer李舒 <[email protected]>2021-06-21 03:39:39 +0000
commit175026ce16ec1af06fe8ebdb28378f81139155ed (patch)
tree3d46f8673dc9bf51525584805349e5a4febab514
parent1a428ed842873d2a80ea09443bd17e6a316da51f (diff)
parentdd10be9f413e6a660d3a43ebd2d8ea566d8e94ee (diff)
Merge branch 'http_head_s2c' into 'master'
处理s2c单向流下,响应体对应的是HEAD方法。 See merge request MESA_Platform/http!10
-rw-r--r--bin/http/http_main.conf3
-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
-rw-r--r--使用说明.md39
8 files changed, 76 insertions, 5 deletions
diff --git a/bin/http/http_main.conf b/bin/http/http_main.conf
index 3476c09..8277d0e 100644
--- a/bin/http/http_main.conf
+++ b/bin/http/http_main.conf
@@ -22,6 +22,9 @@ callback_mode=0
#batch field maxnum when http_all or http_other
batch_field_maxnum=32
+#check HEAD when s2c one-way
+s2c_head_check_switch=1
+
[LOG]
#FATAL:wrong info
#INFO: lostlen; special proc ;proxy info
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ͳ��Э������
***************************************************************
diff --git a/使用说明.md b/使用说明.md
new file mode 100644
index 0000000..f75a4bb
--- /dev/null
+++ b/使用说明.md
@@ -0,0 +1,39 @@
+# 1.�����ļ�˵��
+
+http_main.conf
+
+=================
+
+[FUNCTION]
+switch_no_biz=1
+
+#0 means close stat
+stat_cycle=0
+#stat output screen 0: screen 1: file
+stat_screen_print=0
+stat_file=./log/http/http_stat.log
+
+#ungzip
+ungzip_switch=1
+
+#support proxy
+proxy_switch=1
+
+#single-way traffic need http session num, 0 means no this function
+singleway_maxseq=2
+
+#0: field callback mode(default) 1:batch callback mode
+callback_mode=0
+
+#batch field maxnum when http_all or http_other
+batch_field_maxnum=32
+
+#check HEAD when s2c one-way
+s2c_head_check_switch=1 # ���s2c����������£�Ӧ����Ϣ�Ƿ���HEAD��Ӧ������ǣ�ͷ���е�content-length��ʵ����Ӧ���С��һ�¡�
+
+[LOG]
+#FATAL:wrong info
+#INFO: lostlen; special proc ;proxy info
+#DEBUG: pending and close info; all url;
+log_level=30
+log_path=./log/http/runtime \ No newline at end of file