summaryrefslogtreecommitdiff
path: root/plugin/protocol/http2/src/http2_stream.cpp
diff options
context:
space:
mode:
authorfengweihao <[email protected]>2019-11-19 10:02:51 +0800
committerfengweihao <[email protected]>2019-11-19 10:02:51 +0800
commitba3eb05957eddaa11efa5615df9e61ab030ce123 (patch)
treeef54f0332a5341cd988ce6b47d8cdf5dc7ff0e8f /plugin/protocol/http2/src/http2_stream.cpp
parent8cf94539803ccc11d1d205122d87a422e7a8f469 (diff)
TSG-91
* 修改策略编译配置表名称 * 增加对用户自定域协议字段处理 * 修改配置文件,json文件
Diffstat (limited to 'plugin/protocol/http2/src/http2_stream.cpp')
-rw-r--r--plugin/protocol/http2/src/http2_stream.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/plugin/protocol/http2/src/http2_stream.cpp b/plugin/protocol/http2/src/http2_stream.cpp
index b328183..8f5446a 100644
--- a/plugin/protocol/http2/src/http2_stream.cpp
+++ b/plugin/protocol/http2/src/http2_stream.cpp
@@ -2003,6 +2003,32 @@ nghttp2_client_on_frame_recv(nghttp2_session *session,
return 0;
}
+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 int
nghttp2_client_on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
int32_t stream_id, const uint8_t *input,
@@ -2041,6 +2067,26 @@ nghttp2_client_on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
input = (const uint8_t*)uncompr;
input_len = uncompr_len;
}
+ else
+ {
+ /*if input is end_stream, send by nghttp2_submit_frame_data **/
+ if (flags != NGHTTP2_FLAG_END_STREAM)
+ {
+ /**Decompression failed, send this data**/
+ 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;