summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfengweihao <[email protected]>2019-09-26 19:33:41 +0800
committer冯伟浩 <[email protected]>2019-09-26 19:46:44 +0800
commite94a8bbed4d220690c018c3e5137760422584297 (patch)
tree7db029e8b2ec8e476d05a44b40c4e7e0822668b0
parent8d29fe5cbc2b17490cd41065904e46bcfa373e6a (diff)
* 增加插入js接口,源数据为空判断v4.1.6-20190930
* 删除http2解压缩失败后,主动发送数据函数
-rw-r--r--plugin/business/pangu-http/src/pattern_replace.cpp2
-rw-r--r--plugin/protocol/http2/src/http2_stream.cpp49
2 files changed, 5 insertions, 46 deletions
diff --git a/plugin/business/pangu-http/src/pattern_replace.cpp b/plugin/business/pangu-http/src/pattern_replace.cpp
index 87d0de0..9453cf4 100644
--- a/plugin/business/pangu-http/src/pattern_replace.cpp
+++ b/plugin/business/pangu-http/src/pattern_replace.cpp
@@ -323,7 +323,7 @@ size_t insert_string(char * in, size_t in_sz, const char *insert_on, const char
char* insert_from=NULL;
size_t offset=0;
- if (script == NULL)
+ if (script == NULL || in == NULL)
{
return 0;
}
diff --git a/plugin/protocol/http2/src/http2_stream.cpp b/plugin/protocol/http2/src/http2_stream.cpp
index 4ff47e6..b328183 100644
--- a/plugin/protocol/http2/src/http2_stream.cpp
+++ b/plugin/protocol/http2/src/http2_stream.cpp
@@ -121,10 +121,10 @@ tfe_h2_header_modify_field(struct tfe_h2_header *header, nghttp2_nv *hdrs, const
{
hdrs[nvlen].value = h2_field->nv.value;
hdrs[nvlen].valuelen = h2_field->nv.valuelen;
- }
+ }
hdrs[nvlen].flags = h2_field->nv.flags;
nvlen++;
- }
+ }
return hdrs;
}
@@ -831,32 +831,6 @@ nghttp2_submit_end_data_by_h2_half(struct tfe_h2_stream *h2_stream_info, int32_t
}
static enum tfe_stream_action
-nghttp2_submit_data_by_user(struct tfe_h2_stream *connection,
- struct tfe_h2_session *h2_session,
- enum tfe_conn_dir dir)
-{
- int rv = -1;
- enum tfe_stream_action stream_action = ACTION_DROP_DATA;
-
- struct tfe_h2_half_private *h2_half = tfe_h2_stream_get_half(h2_session, dir);
- nghttp2_session *ngh2_session = tfe_h2_stream_get_nghttp2_session(connection, dir);
-
- struct tfe_h2_payload *body = &h2_half->h2_payload;
-
- nghttp2_data_provider upstream_data_provider;
- upstream_data_provider.source.ptr = (void *)body;
- upstream_data_provider.read_callback = upstream_read_callback;
-
- rv = nghttp2_submit_data(ngh2_session, body->flags,
- h2_session->ngh2_stream_id, &upstream_data_provider);
- if (rv != 0){
- stream_action = ACTION_FORWARD_DATA;
- //printf("Fatal server submit data error: %s\n", nghttp2_strerror(rv));
- }
- return stream_action;
-}
-
-static enum tfe_stream_action
nghttp2_submit_data_by_h2_half(struct tfe_h2_stream *connection,
struct tfe_h2_session *h2_session,
enum tfe_conn_dir dir)
@@ -1869,7 +1843,6 @@ nghttp2_fill_up_header(nghttp2_session *ngh2_session, const nghttp2_frame *frame
frame->headers.cat != NGHTTP2_HCAT_REQUEST){
return 0;
}
-
struct tfe_h2_session *h2_session = (struct tfe_h2_session *)nghttp2_session_get_stream_user_data(ngh2_session, frame->hd.stream_id);
if (!h2_session){
TFE_LOG_ERROR(logger()->handle, "Header stream id %d, can't find stream information",
@@ -2046,8 +2019,9 @@ nghttp2_client_on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
struct tfe_h2_stream *h2_stream_info = (struct tfe_h2_stream *)user_data;
/*proc build resp*/
+ /*when input_len == 1 is end_stream, Nghttp2 sends this frame, drop it*/
struct tfe_h2_session *h2_session = (struct tfe_h2_session *)nghttp2_session_get_stream_user_data(session, stream_id);
- if (h2_session == NULL)
+ if (h2_session == NULL || input_len == 1)
{
return 0;
}
@@ -2067,21 +2041,6 @@ nghttp2_client_on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
input = (const uint8_t*)uncompr;
input_len = uncompr_len;
}
- else
- {
- stream_action = nghttp2_submit_data_by_user(h2_stream_info, h2_session, CONN_DIR_UPSTREAM);
- if (stream_action == ACTION_DROP_DATA)
- {
- xret = nghttp2_session_send(h2_stream_info->as_server);
- if (xret != 0)
- {
- stream_action = ACTION_FORWARD_DATA;
- TFE_LOG_ERROR(logger()->handle, "Fatal upstream(%d) send error: %s\n",stream_id, nghttp2_strerror(xret));
- }
- }
- h2_stream_info->stream_action = stream_action;
- return 0;
- }
}
data = input;
len = input_len;