1.修改http2无法发送策略日志

2.修改命中hjack无法处理
This commit is contained in:
fengweihao
2019-06-05 11:44:26 +08:00
parent b5ec503583
commit a3bba9f5e2
3 changed files with 59 additions and 30 deletions

View File

@@ -584,14 +584,13 @@ tfe_half_private_init(enum tfe_http_direction direction, int32_t stream_id,
struct tfe_h2_half_private *half_private = ALLOC(struct tfe_h2_half_private, 1);
assert(half_private);
memset(half_private, 0, sizeof(struct tfe_h2_half_private));
half_private->half_public.direction = direction;
half_private->half_public.major_version = 2;
half_private->half_public.ops = &h2_half_ops;
headers_init(&half_private->header);
headers_init(&half_private->promised);
half_private->h2_payload.inflate = NULL;
half_private->h2_payload.deflate = NULL;
half_private->h2_payload.evbuf_body = evbuffer_new();
half_private->h2_payload.gzip = HTTP2_CONTENT_ENCODING_NONE;
half_private->h2_payload.padlen = 0;
@@ -963,7 +962,7 @@ nghttp2_submit_frame_goaway(struct tfe_h2_stream *connection, const nghttp2_fram
{
int xret = -1;
enum tfe_stream_action stream_action = ACTION_DROP_DATA;
char error[1024] = {0};
char *error = NULL; size_t eroro_len=0;
const nghttp2_goaway *goaway = &frame->goaway;
nghttp2_session *ngh2_session = tfe_h2_stream_get_nghttp2_session(connection, dir);
@@ -983,10 +982,12 @@ nghttp2_submit_frame_goaway(struct tfe_h2_stream *connection, const nghttp2_fram
dir, nghttp2_strerror(xret));
}
finish:
snprintf(error, goaway->opaque_data_len, "%s", goaway->opaque_data);
eroro_len = goaway->opaque_data_len;
error = ALLOC(char, eroro_len + 1);
snprintf(error, eroro_len, "%s", goaway->opaque_data);
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit goaway, stream_id:%d, action:%d, errod_code:%d, data:%s", connection->tf_stream->str_stream_info,
dir, goaway->last_stream_id, connection->stream_action, goaway->error_code, goaway->opaque_data);
FREE(&error);
connection->goaway = 1;
connection->stream_action = stream_action;
return 0;
@@ -1129,6 +1130,7 @@ static int tfe_half_session_init(struct tfe_h2_session *h2_session, int32_t stre
{
struct tfe_http_session *tfe_session = &h2_session->tfe_session;
tfe_session->major_version = 2;
if (direction == TFE_HTTP_REQUEST){
struct tfe_h2_half_private *req = h2_session->req;
tfe_session->ops = &nghttp2_session_ops;
@@ -1791,9 +1793,14 @@ nghttp2_on_stream_close(nghttp2_session *session, const nghttp2_frame *frame, co
h2_stream_info->stream_action != ACTION_DEFER_DATA)
nghttp2_submit_end_header(h2_stream_info, h2_session);
goto end;
}
}
finish:
TAILQ_REMOVE(&h2_stream_info->h2_session_list, h2_session, next);
if (h2_session->frame_ctx){
http_frame_raise_session_end(h2_session->frame_ctx, h2_session->tf_stream, &h2_session->tfe_session,
h2_stream_info->thread_id);
h2_session->frame_ctx = NULL;
}
delete_http2_stream_data(h2_session, h2_stream_info->tf_stream, 1);
free(h2_session);
h2_session = NULL;
@@ -1870,6 +1877,9 @@ nghttp2_client_on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
if (((ret == Z_STREAM_END) || (ret == Z_OK)) && uncompr > 0){
input = (const uint8_t*)uncompr;
input_len = uncompr_len;
}else
{
if (uncompr_len) FREE(&uncompr);
}
}
data = input;
@@ -2186,6 +2196,10 @@ nghttp2_server_on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
input = (const uint8_t*)uncompr;
input_len = uncompr_len;
}
else
{
if (uncompr_len) FREE(&uncompr);
}
}
data = input;
len = input_len;