diff options
| author | luwenpeng <[email protected]> | 2019-09-24 11:06:38 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2019-09-24 11:15:00 +0800 |
| commit | afa3bed4aee5da4d246c097f3503d6ab009736be (patch) | |
| tree | 88570792bf077a3d636748fc1eba0da447909dc6 /plugin/protocol/http2/src/http2_stream.cpp | |
| parent | 7c99fddde98afe2e362e0a0785810a861a7d4c3b (diff) | |
#174 在 http2 解析 header 时,修改 headerlength 的获取方式
* 原来是使用 strlen(header) 获取 headerlength
* 现在改为使用 http2 callback 传入的 headerlength
暗示着 header 字段可能不以 '\0' 结尾
Diffstat (limited to 'plugin/protocol/http2/src/http2_stream.cpp')
| -rw-r--r-- | plugin/protocol/http2/src/http2_stream.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/plugin/protocol/http2/src/http2_stream.cpp b/plugin/protocol/http2/src/http2_stream.cpp index 2f88dba..29f8c69 100644 --- a/plugin/protocol/http2/src/http2_stream.cpp +++ b/plugin/protocol/http2/src/http2_stream.cpp @@ -1872,7 +1872,8 @@ nghttp2_fill_up_header(nghttp2_session *ngh2_session, const nghttp2_frame *frame struct tfe_h2_half_private *half = (dir == CONN_DIR_UPSTREAM) ? h2_session->resp : h2_session->req; struct http_field_name field; - field.field_id = (enum tfe_http_std_field)http2_header_str_to_val((const char *)name, __str_std_header_field_map, __str_std_header_field_map_size); + // "name" may not terminated with '\0', so use "namelen" + field.field_id = (enum tfe_http_std_field)http2_header_str_to_val((const char *)name, namelen, __str_std_header_field_map, __str_std_header_field_map_size); if (field.field_id == TFE_HTTP_UNKNOWN_FIELD) { field.field_name = (const char *)name; @@ -1906,7 +1907,8 @@ nghttp2_fill_up_promise(nghttp2_session *ngh2_session, const nghttp2_frame *fram } resp = h2_session->resp; struct http_field_name field; - field.field_id = (enum tfe_http_std_field)http2_header_str_to_val((const char *)name, __str_std_header_field_map, __str_std_header_field_map_size); + // "name" may not terminated with '\0', so use "namelen" + field.field_id = (enum tfe_http_std_field)http2_header_str_to_val((const char *)name, namelen, __str_std_header_field_map, __str_std_header_field_map_size); if (field.field_id == TFE_HTTP_UNKNOWN_FIELD) { field.field_name = (const char *)name; |
