summaryrefslogtreecommitdiff
path: root/plugin/protocol/http2/src/http2_common.cpp
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2019-09-24 11:06:38 +0800
committerluwenpeng <[email protected]>2019-09-24 11:15:00 +0800
commitafa3bed4aee5da4d246c097f3503d6ab009736be (patch)
tree88570792bf077a3d636748fc1eba0da447909dc6 /plugin/protocol/http2/src/http2_common.cpp
parent7c99fddde98afe2e362e0a0785810a861a7d4c3b (diff)
#174 在 http2 解析 header 时,修改 headerlength 的获取方式
* 原来是使用 strlen(header) 获取 headerlength * 现在改为使用 http2 callback 传入的 headerlength 暗示着 header 字段可能不以 '\0' 结尾
Diffstat (limited to 'plugin/protocol/http2/src/http2_common.cpp')
-rw-r--r--plugin/protocol/http2/src/http2_common.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/plugin/protocol/http2/src/http2_common.cpp b/plugin/protocol/http2/src/http2_common.cpp
index f4b7007..b8b2a2c 100644
--- a/plugin/protocol/http2/src/http2_common.cpp
+++ b/plugin/protocol/http2/src/http2_common.cpp
@@ -36,11 +36,13 @@ Http2Plugin *http2_plugin()
}
int
-http2_header_str_to_val(const char *str, const char * map[], unsigned int map_size)
+http2_header_str_to_val(const char *str, size_t slen, const char * map[], unsigned int map_size)
{
+ size_t normlen = 0;
for (unsigned int i = 2; i < map_size; i++)
{
- if ( (strlen(str) == strlen(map[i])) && !strncasecmp(str, map[i], strlen(map[i])))
+ normlen = strlen(map[i]);
+ if ( (slen == normlen) && !strncasecmp(str, map[i], normlen))
{
return i;
}
@@ -48,7 +50,8 @@ http2_header_str_to_val(const char *str, const char * map[], unsigned int map_si
// in http [TFE_HTTP_UNKNOWN_FIELD] = NULL; [TFE_HTTP_HOST] = "Host",
// in http2 [TFE_HTTP_UNKNOWN_FIELD] = "unknown"; [TFE_HTTP_HOST] = ":authority"
- if ( (strlen(str) == strlen(":authority")) && !strncasecmp(str, ":authority", strlen(":authority")))
+ normlen = strlen(":authority");
+ if ( (slen == normlen) && !strncasecmp(str, ":authority", normlen))
{
return TFE_HTTP_HOST;
} else {