From 0fc69f46ddc8d179de9083670930879d816c8df0 Mon Sep 17 00:00:00 2001 From: yangwei Date: Thu, 13 Apr 2023 11:45:40 +0800 Subject: 🧪 test(unit test): 移除http_test,http parser测试用例加入到gtest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/HTTP_Message.c | 2 - src/HTTP_Message.h | 14 ++--- src/HTTP_Test.c | 167 ----------------------------------------------------- 3 files changed, 6 insertions(+), 177 deletions(-) delete mode 100644 src/HTTP_Test.c (limited to 'src') 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 -#include -#include -#include -#include -#include -#include -#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