summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2023-04-13 11:45:40 +0800
committeryangwei <[email protected]>2023-04-13 11:45:40 +0800
commit0fc69f46ddc8d179de9083670930879d816c8df0 (patch)
treeff3e1e06a40babf7ab63d512458a769b7369b959
parent177fac792dace1bce90964d88509e81a34e6fc59 (diff)
🧪 test(unit test): 移除http_test,http parser测试用例加入到gtest
-rw-r--r--src/HTTP_Message.c2
-rw-r--r--src/HTTP_Message.h14
-rw-r--r--src/HTTP_Test.c167
-rw-r--r--test/unit_test.cpp192
4 files changed, 196 insertions, 179 deletions
diff --git a/src/HTTP_Message.c b/src/HTTP_Message.c
index ae9ccd7..a6822e7 100644
--- a/src/HTTP_Message.c
+++ b/src/HTTP_Message.c
@@ -544,8 +544,6 @@ int HTTP_INIT(void)
}
}
- /*http test*/
- http_test();
return 0;
}
diff --git a/src/HTTP_Message.h b/src/HTTP_Message.h
index a1107e3..18b65d1 100644
--- a/src/HTTP_Message.h
+++ b/src/HTTP_Message.h
@@ -71,7 +71,7 @@
#define HTTP_STAT_HEADER_SPAN_BYTE 27
#define HTTP_MAX_STAT_FIELD 28
-/*������룬û��chunk��û��cont-length*/
+/*������룬û��chunk��û��cont-length*/
#define HTTP_TRANS_ENCOD_CNNTCLOSE 0X04//connection close
#define HTTP_CHUNK_STATE_UNKONWN 0X00
@@ -126,8 +126,8 @@ typedef struct _session_infor_t
typedef struct _fold_infor_t
{
- void* buf; //�۵��л�����
- int buflen; //�۵��л�������С
+ void* buf; //�۵��л�����
+ int buflen; //�۵��л�������С
}fold_infor_t;
typedef struct _fold_buf_t
@@ -154,9 +154,9 @@ typedef struct _http_parser_t
char* phttp_begin;
uint32 poneline_datalen;
- uint32 processed_offset; //�Ѵ��������ڵ�ǰ����ƫ����,��������һ������Ҫ����
+ uint32 processed_offset; //�Ѵ��������ڵ�ǰ����ƫ����,��������һ������Ҫ����
- uint64 packet_entity_len; //δ������ʵ�峤��
+ uint64 packet_entity_len; //δ������ʵ�峤��
docanalyze_streamparam_t ungzip_handle;
uint64 acc_cont_length;
int64 batch_prot_flag;
@@ -184,7 +184,7 @@ typedef struct _http_prog_runtime_parameter_t
FILE* http_stat_file;
void* http_log_handle;
- void* region_hash; //��չ���ʶ��
+ void* region_hash; //��չ���ʶ��
void* stat_handler;
void* docanly_handler;
@@ -232,8 +232,6 @@ struct http_proto_tag_t
char buf[8];
};
-void http_test();
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/src/HTTP_Test.c b/src/HTTP_Test.c
deleted file mode 100644
index 1595db5..0000000
--- a/src/HTTP_Test.c
+++ /dev/null
@@ -1,167 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <pthread.h>
-#include <dlfcn.h>
-#include <math.h>
-#include <stream.h>
-#include "inc/http_parser.h"
-#include "HTTP_Common.h"
-#include "http.h"
-
-
-/*http_host_parser_test Э��ʶ������,host��������*/
-static const char * http_request =
- /*
- "POST /gen_204 HTTP/1.1\r\n"
- "Host: www.google.com\r\n"
- "Connection: close\r\n"
- "Content-Length: 0\r\n"
- "Origin: https://www.google.com\r\n"
- "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36\r\n"
- "Content-Type: text/plain;charset=UTF-8\r\n"
- "X-Client-Data: CJG2yQEIorbJAQjEtskBCKmdygEI2J3KAQjZncoBCKijygEY+aXKAQ==\r\n"
- "Referer: https://www.google.com/\r\n"
- "Accept-Encoding: gzip, deflate\r\n"
- "Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7\r\n";
- */
-
- "GET sampleFile.html HTTP/1.1\r\nUser-Agent:xPTS/2.0\r\n"; //http_parser����ʧ�ܣ�uri��/��ʼ
-
-
-/*http_host_parser_test Э��ʶ������,��host�ֶ�*/
-static const char * http_request_no_host =
- "POST /gen_204 HTTP/1.1\r\n"
- "Connection: close\r\n"
- "Content-Length: 0\r\n"
- "Origin: https://www.google.com\r\n"
- "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36\r\n"
- "Content-Type: text/plain;charset=UTF-8\r\n"
- "Accept: */*\r\n"
- "X-Client-Data: CJG2yQEIorbJAQjEtskBCKmdygEI2J3KAQjZncoBCKijygEY+aXKAQ==\r\n"
- "Referer: https://www.google.com/\r\n"
- "Accept-Encoding: gzip, deflate\r\n"
- "Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7\r\n";
-
-/*http_host_parser_test Э��ʶ������*/
-static const char * http_response =
- //"HTTP/1.1 200 OK\r\nAccept-Ranges: bytes\r\nVary: Accept-Encoding\r\nContent-Type: text/javascript; charset=UTF-8\r\nContent-Length: 4064\r\nAge: 8963\r\n";
- "HTTP/1.1 200 OK\r\nDate: Mon, 25 Oct 2004 23:59:59 GMT\r\nContent-Type: text/html\r\nServer: xPTS/2.0 (Red.Hat.Linux)";
-
-/*http_host_parser_test Э��ʶ��������host����ʧ�ܣ���֧��\r*/
-static const char * http_request_CR =
- "POST /gen_204 HTTP/1.1\r"
- "Host: www.google.com\r"
- "Connection: close\r"
- "Content-Length: 0\r"
- "Origin: https://www.google.com\r"
- "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36\r\n"
- "Content-Type: text/plain;charset=UTF-8\r";
-
-/*http_host_parser_test Э��ʶ������������ʧ��*/
-static const char * http_reponse_CR =
- "HTTP/1.1 200 OK\r"
- "Accept-Ranges: bytes\r"
- "Vary: Accept-Encoding\r\nContent-Type: text/javascript; charset=UTF-8\r\nContent-Length: 4064\r\nAge: 8963\r\n";
-
-/*/*http_host_parser_test Э��ʶ���������������hostΪclose����֧�ִ����*/
-static const char * http_request_LF =
- "POST /gen_204 HTTP/1.1\n"
- "host: \n"
- "Connection: close\n"
- "Content-Length: 0\n"
- "Origin: https://www.google.com\n";
-
-/*http_host_parser_test Э��ʶ������,host��������*/
-static const char * http_request_SPACE =
- "POST /gen_204 HTTP/1.1\r\n"
- "HOST: www. google.com \r\n";
-
-/*http_host_parser_test Э��ʶ������,host��������*/
-static const char * http_request_incpomplete =
- "POST /gen_204 HTTP/1.1\n"
- "Host: www.googl";
-
-/*http_host_parser_test Э��ʶ������,host��������*/
-static const char * http_request_with_body =
- "POST /gen_204 HTTP/1.1\r\n"
- "Host: www.google.com\r\n"
- "Connection: close\r\n"
- "Content-Length: 0\r\n"
- "Origin: https://www.google.com\r\n"
- "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36\r\n"
- "Content-Type: text/plain;charset=UTF-8\r\n"
- "Accept: */*\r\n"
- "X-Client-Data: CJG2yQEIorbJAQjEtskBCKmdygEI2J3KAQjZncoBCKijygEY+aXKAQ==\r\n"
- "Referer: https://www.google.com/\r\n"
- "Accept-Encoding: gzip, deflate\r\n"
- "Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7\r\n"
- "\r\n"
- "abcdjhjkhdlaks";
-
-/*http_host_parser_test Э��ʶ������,host��������*/
-static const char * http_request_space_start =
- "\r \nPOST /gen_204 HTTP/1.1\r\n"
- "Host: www.google.com\r\n"
- "Connection: close\r\n"
- "Content-Length: 0\r\n"
- "Origin: https://www.google.com\r\n"
- "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36\r\n"
- "Content-Type: text/plain;charset=UTF-8\r\n"
- "Accept: */*\r\n"
- "X-Client-Data: CJG2yQEIorbJAQjEtskBCKmdygEI2J3KAQjZncoBCKijygEY+aXKAQ==\r\n"
- "Referer: https://www.google.com/\r\n"
- "Accept-Encoding: gzip, deflate\r\n"
- "Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7\r\n"
- "\r\n"
- "abcdjhjkhdlaks";
-
-
-void http_host_parser_test(const char* test_buf, int test_buf_dir)
-{
- char* host = NULL;
- uint32 hostlen = 0;
- int rec = -1;
-
- /*�ж��Ƿ���httpЭ������*/
- rec = http_host_parser((const char*)test_buf, (uint32)strlen(test_buf), test_buf_dir, NULL);
- if(-1==rec)
- {
- printf("not http data\n");
- }
- else if(0==rec)
- {
- printf("is http data\n");
- }
-
- /*�ж��Ƿ���httpЭ�����ݣ�����ȡhost�ֶ�����*/
- rec = http_host_parser((const char*)test_buf, (uint32)strlen(test_buf), test_buf_dir, &host);
- if(-1==rec)
- {
- printf("not http data\n");
- }
- else if(0<=rec)
- {
- printf("is http data\n");
- if(0<rec)
- {
- printf("HOST: %.*s\n", (int)rec, host);
- }
- }
- printf("http_host_parser_test end!!!!!!!!!!!!!!!!!!!!!!!!!\n\n");
-}
-
-void http_test()
-{
- /*http_host_parser_test����*/
- //http_host_parser_test(http_request, DIR_C2S);
- //http_host_parser_test(http_request_no_host, DIR_C2S);
- //http_host_parser_test(http_response, DIR_S2C);
- //http_host_parser_test(http_request_CR, DIR_C2S);
- //http_host_parser_test(http_reponse_CR, DIR_S2C);
- //http_host_parser_test(http_request_LF, DIR_C2S);
- //http_host_parser_test(http_request_SPACE, DIR_C2S);
- //http_host_parser_test(http_request_incpomplete, DIR_C2S);
- //http_host_parser_test(http_request_with_body, DIR_C2S);
- //http_host_parser_test(http_request_space_start, DIR_C2S);
-}
diff --git a/test/unit_test.cpp b/test/unit_test.cpp
index 0f6ae71..3ab6b45 100644
--- a/test/unit_test.cpp
+++ b/test/unit_test.cpp
@@ -5,7 +5,7 @@
#include "http.h"
-TEST(HTTPUnitTest, url_decode1)
+TEST(url_decode, chinese)
{
const char *input = "%A9%E4%B8%8B%E8%B6%B3%E7%90%83%2CRB%E8%8E%B1%E6%AF%94%E9%94%A1%2C%E5%BC%97%E8%B5%96%E5%A0%A1%2C%E6%96%AF%E6%89%98%E5%85%8B%E5%9F%8E%2C%E4%BC%AF%E6%81%A9%E8%8C%85%E6%96%AF%2C%E9%97%A8%E5%85%B4%2C%E8%90%A8%E7%B4%A2%E6%B4%9B%2C%E8%B6%B3%E7%90%83%2C%E7%9A%87%E5%AE%B6%E7%A4%BE%E4%BC%9A%2C%E8%8B%B1%E8%B6%85%2C%E6%9B%BC%E5%BD%BB%E6%96%AF%E7%89%B9%E8%81%94%2C%E5%9F%83%E7%93%A6%E5%B0%94%2C%E8%A5%BF%E4%B9%99%2C%E6%B3%95%E5%85%B0%E5%85%8B%E7%A6%8F%2C%E6%8B%89%E6%96%AF%E5%B8%95%E5%B0%94%E9%A9%AC%E6%96%AF%2C%E6%B2%99%E5%B0%94%E5%85%8B%2C%E7%9A%87%E5%AE%B6%E9%A9%AC%E5%BE%B7%E9%87%8C%2C%E7%83%AD%E9%82%A3%E4%BA%9A%2C%E7%BE%8E%E5%9B%A0%E8%8C%A8%2C%E5%B7%B4%E8%90%A8%2C%E8%8E%B1%E6%AF%94%E9%94%A1%E7%BA%A2%E7%89%9B%2C%E6%96%AF%E5%9B%BE%E5%8A%A0%E7%89%B9%2CCBA%2C%E5%A5%A5%E8%90%A8%E8%8B%8F%E7%BA%B3%2C%E6%8B%9C%E4%BB%81%E6%85%95%E5%B0%BC%E9%BB%91%2C%E8%B5%AB%E7%BD%97%E7%BA%B3%2C%E6%81%A9%E6%B3%A2%E5%88%A9%2C%E6%AF%95%E5%B0%94%E5%B7%B4%E9%84%82%2C%E5%A1%9E%E5%B0%94%E5%A1%94%2C%E7%9A%87%E5%AE%B6%E8%B4%9D%E8%92%82%E6%96%AF%2C%E6%B2%8";
int len = strlen(input);
@@ -21,7 +21,7 @@ TEST(HTTPUnitTest, url_decode1)
}
-TEST(HTTPUnitTest, url_decode2)
+TEST(url_decode, no_result)
{
const char *input = "76%253AB%257C1811%253AD%257C1875%253AB%257C1876%253AB%257C1877%253AB%257C1879%253AB%257C2041%253AA%257C2074%253AB%257C2075%253AB%257C2122%253AB%257C2176%253AB%257C2287%253AC%257C2319%253AB%257C2906%253AB%257C3025%253AP%257C3200%253AG%257C3201%253AD%257C3204%253AC%257C3205%253AB%257C3256%253AD%257C3270%253AB%257C3502%253AR%257C3600%253AB%257C3661%253AA%257C3759%253AC%257C3853%253AC%257C3879%253AK%257C3906%253AD%257C3940%253AD%257C4030%253AB%257C4072%253AC%257C4079%253AB%257C4081%253AC%257C4099%253AC%257C4105%253AL%257C4163%253AC%257C4320%253AA%257C4328%253AE%257C4330%253AD%257C4357%253AC%257C4361%253AB%257C4428%253AA%257C4447%253AC%257C4449%253AB%257C4450%253AB%257C4453%253AE%257C4454%253AD%257C4531%253AA%257C4551%253AF%257C4576%253AH%257C4577%253AD%257C4589%253AB%257C4612%253AE%257C4669%253AB%257C4702%253AB%257C4773%253AB%257C4827%253AA%257C4887%253AC%257C4920%253AC%257C4921%253AA%257C4935%253AB%257C4937%253AC%257C4957%253AA%257C5001%253AB%257C5020%253AC%257C5183%253AB%257C5547%253AB%257C5643%253AA%257C5889%2";
int len = strlen(input);
@@ -37,6 +37,194 @@ TEST(HTTPUnitTest, url_decode2)
}
+#define DIR_C2S 0x01
+#define DIR_S2C 0x02
+
+TEST(http_host_parser, http_request)
+{
+
+/*http_host_parser_test 协议识别正常,host解析正常*/
+ const char * test_buff =
+ /*
+ "POST /gen_204 HTTP/1.1\r\n"
+ "Host: www.google.com\r\n"
+ "Connection: close\r\n"
+ "Content-Length: 0\r\n"
+ "Origin: https://www.google.com\r\n"
+ "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36\r\n"
+ "Content-Type: text/plain;charset=UTF-8\r\n"
+ "X-Client-Data: CJG2yQEIorbJAQjEtskBCKmdygEI2J3KAQjZncoBCKijygEY+aXKAQ==\r\n"
+ "Referer: https://www.google.com/\r\n"
+ "Accept-Encoding: gzip, deflate\r\n"
+ "Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7\r\n";
+ */
+
+ "GET sampleFile.html HTTP/1.1\r\nUser-Agent:xPTS/2.0\r\n"; //http_parser解析失败,uri以/开始
+
+ char* host = NULL;
+ int rec = http_host_parser((const char*)test_buff, (uint32)strlen(test_buff), DIR_C2S, &host);
+ EXPECT_EQ(rec,0);
+ EXPECT_TRUE(host==NULL);
+}
+
+TEST(http_host_parser, http_request_no_host)
+{
+/*http_host_parser_test 协议识别正常,无host字段*/
+ const char * test_buff =
+ "POST /gen_204 HTTP/1.1\r\n"
+ "Connection: close\r\n"
+ "Content-Length: 0\r\n"
+ "Origin: https://www.google.com\r\n"
+ "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36\r\n"
+ "Content-Type: text/plain;charset=UTF-8\r\n"
+ "Accept: */*\r\n"
+ "X-Client-Data: CJG2yQEIorbJAQjEtskBCKmdygEI2J3KAQjZncoBCKijygEY+aXKAQ==\r\n"
+ "Referer: https://www.google.com/\r\n"
+ "Accept-Encoding: gzip, deflate\r\n"
+ "Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7\r\n";
+
+ char* host = NULL;
+ int rec = http_host_parser((const char*)test_buff, (uint32)strlen(test_buff), DIR_C2S, &host);
+ EXPECT_EQ(rec,0);
+ EXPECT_TRUE(host==NULL);
+}
+
+
+TEST(http_host_parser, http_response)
+{
+/*http_host_parser_test 协议识别正常*/
+ const char * test_buff =
+ //"HTTP/1.1 200 OK\r\nAccept-Ranges: bytes\r\nVary: Accept-Encoding\r\nContent-Type: text/javascript; charset=UTF-8\r\nContent-Length: 4064\r\nAge: 8963\r\n";
+ "HTTP/1.1 200 OK\r\nDate: Mon, 25 Oct 2004 23:59:59 GMT\r\nContent-Type: text/html\r\nServer: xPTS/2.0 (Red.Hat.Linux)";
+ char* host = NULL;
+ int rec = http_host_parser((const char*)test_buff, (uint32)strlen(test_buff), DIR_S2C, &host);
+ EXPECT_EQ(rec,0);
+ EXPECT_TRUE(host==NULL);
+}
+
+TEST(http_host_parser, http_request_CR)
+{
+/*http_host_parser_test 协议识别正常,host解析失败,不支持\r*/
+static const char * test_buff =
+ "POST /gen_204 HTTP/1.1\r"
+ "Host: www.google.com\r"
+ "Connection: close\r"
+ "Content-Length: 0\r"
+ "Origin: https://www.google.com\r"
+ "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36\r\n"
+ "Content-Type: text/plain;charset=UTF-8\r";
+ char* host = NULL;
+ int rec = http_host_parser((const char*)test_buff, (uint32)strlen(test_buff), DIR_C2S, &host);
+ EXPECT_EQ(rec,0);
+ EXPECT_TRUE(host==NULL);
+}
+
+TEST(http_host_parser, http_reponse_CR)
+{
+/*http_host_parser_test 协议识别正常,解析失败*/
+ const char * test_buff =
+ "HTTP/1.1 200 OK\r"
+ "Accept-Ranges: bytes\r"
+ "Vary: Accept-Encoding\r\nContent-Type: text/javascript; charset=UTF-8\r\nContent-Length: 4064\r\nAge: 8963\r\n";
+
+ char* host = NULL;
+ int rec = http_host_parser((const char*)test_buff, (uint32)strlen(test_buff), DIR_S2C, &host);
+ EXPECT_EQ(rec,0);
+ EXPECT_TRUE(host==NULL);
+}
+
+TEST(http_host_parser, http_request_LF)
+{
+/*/*http_host_parser_test 协议识别情况正常,但是host为close,不支持此情况*/
+ const char * test_buff =
+ "POST /gen_204 HTTP/1.1\n"
+ "host: \n"
+ "Connection: close\n"
+ "Content-Length: 0\n"
+ "Origin: https://www.google.com\n";
+ char* host = NULL;
+ int rec = http_host_parser((const char*)test_buff, (uint32)strlen(test_buff), DIR_C2S, &host);
+ EXPECT_EQ(rec,5);
+ EXPECT_EQ(memcmp(host, "close", rec),0);
+}
+
+
+
+TEST(http_host_parser, http_request_SPACE)
+{
+/*http_host_parser_test 协议识别正常,host解析正常*/
+const char * test_buff =
+ "POST /gen_204 HTTP/1.1\r\n"
+ "HOST: www. google.com \r\n";
+ char* host = NULL;
+ int rec = http_host_parser((const char*)test_buff, (uint32)strlen(test_buff), DIR_C2S, &host);
+ EXPECT_EQ(rec,28);
+ EXPECT_EQ(memcmp(host, "www. google.com \r\n", rec),0);
+}
+
+TEST(http_host_parser, http_request_incpomplete)
+{
+/*http_host_parser_test 协议识别正常,host解析正常*/
+ const char * test_buff =
+ "POST /gen_204 HTTP/1.1\n"
+ "Host: www.googl";
+ char* host = NULL;
+ int rec = http_host_parser((const char*)test_buff, (uint32)strlen(test_buff), DIR_C2S, &host);
+ EXPECT_EQ(rec,9);
+ EXPECT_EQ(memcmp(host, "www.googl", rec),0);
+}
+
+TEST(http_host_parser, http_request_with_body)
+{
+/*http_host_parser_test 协议识别正常,host解析正常*/
+ const char * test_buff =
+ "POST /gen_204 HTTP/1.1\r\n"
+ "Host: www.google.com\r\n"
+ "Connection: close\r\n"
+ "Content-Length: 0\r\n"
+ "Origin: https://www.google.com\r\n"
+ "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36\r\n"
+ "Content-Type: text/plain;charset=UTF-8\r\n"
+ "Accept: */*\r\n"
+ "X-Client-Data: CJG2yQEIorbJAQjEtskBCKmdygEI2J3KAQjZncoBCKijygEY+aXKAQ==\r\n"
+ "Referer: https://www.google.com/\r\n"
+ "Accept-Encoding: gzip, deflate\r\n"
+ "Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7\r\n"
+ "\r\n"
+ "abcdjhjkhdlaks";
+
+ char* host = NULL;
+ int rec = http_host_parser((const char*)test_buff, (uint32)strlen(test_buff), DIR_C2S, &host);
+ EXPECT_EQ(rec,14);
+ EXPECT_EQ(memcmp(host, "www.google.com\r\n", rec),0);
+}
+
+TEST(http_host_parser, http_request_space_start)
+{
+/*http_host_parser_test 协议识别正常,host解析正常*/
+ const char * test_buff =
+ "\r \nPOST /gen_204 HTTP/1.1\r\n"
+ "Host: www.google.com\r\n"
+ "Connection: close\r\n"
+ "Content-Length: 0\r\n"
+ "Origin: https://www.google.com\r\n"
+ "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36\r\n"
+ "Content-Type: text/plain;charset=UTF-8\r\n"
+ "Accept: */*\r\n"
+ "X-Client-Data: CJG2yQEIorbJAQjEtskBCKmdygEI2J3KAQjZncoBCKijygEY+aXKAQ==\r\n"
+ "Referer: https://www.google.com/\r\n"
+ "Accept-Encoding: gzip, deflate\r\n"
+ "Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7\r\n"
+ "\r\n"
+ "abcdjhjkhdlaks";
+
+ char* host = NULL;
+ int rec = http_host_parser((const char*)test_buff, (uint32)strlen(test_buff), DIR_C2S, &host);
+ EXPECT_EQ(rec,14);
+ EXPECT_EQ(memcmp(host, "www.google.com\r\n", rec),0);
+}
+
+
int main(int argc, char ** argv)
{