diff options
| author | liuxueli <[email protected]> | 2021-09-15 10:20:58 +0800 |
|---|---|---|
| committer | liuxueli <[email protected]> | 2021-09-15 10:20:58 +0800 |
| commit | 014ff01e3148d6e6de9148a3b64a8e7d7c2340e3 (patch) | |
| tree | 7c8cf666ae4ab11af84471e66c5e06e96ea1c3bb | |
| parent | d5488fcc51c1b612198282bbbe9c9a480b6da463 (diff) | |
TSG-7762: http解析层支持支持URI可以不以'/'开始进行解析,http_host_parser重新申请空间,返回host指针指向的是新申请的空间内存,http_host_parser函数结束时释放新申请的空间v2.0.7
| -rw-r--r-- | src/HTTP_Parser.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/HTTP_Parser.c b/src/HTTP_Parser.c index 3b63e81..19fe4de 100644 --- a/src/HTTP_Parser.c +++ b/src/HTTP_Parser.c @@ -84,7 +84,7 @@ int http_host_parser(const char* buf, uint32 buflen, int http_dir, char** host) char* new_pbuf = NULL; uint32 new_pbuflen = 0; uchar method = HTTP_METHOD_UNKNOWN; - int method_idx = 1; + int method_idx = 1, new_flags=0; //printf("buf=====================================================\n"); //printf("%s\n", buf); @@ -120,8 +120,9 @@ int http_host_parser(const char* buf, uint32 buflen, int http_dir, char** host) memcpy(new_pbuf, pbuf, pbuflen-pbuflen_temp); memcpy(new_pbuf+pbuflen-pbuflen_temp, "/", strlen("/")); memcpy(new_pbuf+pbuflen-pbuflen_temp+strlen("/"), pbuf+pbuflen-pbuflen_temp, pbuflen_temp); - pbuf = new_pbuf; - pbuflen = new_pbuflen; + //pbuf = new_pbuf; + //pbuflen = new_pbuflen; + new_flags=1; } } } @@ -137,9 +138,17 @@ int http_host_parser(const char* buf, uint32 buflen, int http_dir, char** host) { ((host_parser*)(parser->data))->get_host_flag = 1; } - + + size_t parsed=0; //ִ�н������� - size_t parsed = http_parser_execute(parser, &http_setting, pbuf, (size_t)pbuflen); + if(new_flags==0) + { + parsed=http_parser_execute(parser, &http_setting, pbuf, (size_t)pbuflen); + } + else + { + parsed=http_parser_execute(parser, &http_setting, new_pbuf, (size_t)new_pbuflen); + } //printf("buflen: %d; parsed: %d\n", pbuflen, parsed); if(((host_parser*)(parser->data))->is_http_flag == 1) { @@ -149,7 +158,7 @@ int http_host_parser(const char* buf, uint32 buflen, int http_dir, char** host) if(0<host_field->host_valuelen) { rec = host_field->host_valuelen; - *host = memcasemem(pbuf, pbuflen, (const char*)host_field->host_value, host_field->host_valuelen); + *host = memcasemem(pbuf, pbuflen, (const char*)host_field->host_value, host_field->host_valuelen); } } } |
