* 修改策略编译配置表名称
* 增加对用户自定域协议字段处理
* 修改配置文件,json文件
This commit is contained in:
fengweihao
2019-11-19 10:02:51 +08:00
parent 8cf9453980
commit ba3eb05957
8 changed files with 175 additions and 80 deletions

View File

@@ -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;