diff --git a/plugin/business/pangu-http/src/pangu_http.cpp b/plugin/business/pangu-http/src/pangu_http.cpp index 16da3ae..0a373da 100644 --- a/plugin/business/pangu-http/src/pangu_http.cpp +++ b/plugin/business/pangu-http/src/pangu_http.cpp @@ -1434,8 +1434,8 @@ void http_replace(const struct tfe_stream * stream, const struct tfe_http_sessio rewrite_buff = NULL; rewrite_sz = 0; - if (tfe_http_in_response(events) && in_resp_spec->content_type != NULL - && strcasestr(in_resp_spec->content_type, "utf-8")) + if ((tfe_http_in_response(events) && in_resp_spec->content_type != NULL + && strcasestr(in_resp_spec->content_type, "utf-8")) || tfe_http_in_request(events)) { options = 1; } @@ -1555,10 +1555,8 @@ static void http_redirect(const struct tfe_http_session * session, enum tfe_http { assert(0); } - if(ctx->enforce_rules[0].do_log > 0) - { - ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REDIRECT])); - } + + ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REDIRECT])); response = tfe_http_session_response_create(to_write, resp_code); tfe_http_std_field_write(response, TFE_HTTP_LOCATION, rd_url); @@ -1610,10 +1608,7 @@ static void http_block(const struct tfe_http_session * session, enum tfe_http_ev snprintf(cont_len_str, sizeof(cont_len_str), "%lu", page_size); tfe_http_std_field_write(response, TFE_HTTP_CONT_LENGTH, cont_len_str); - if(ctx->enforce_rules[0].do_log > 0) - { - ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REJECT])); - } + ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REJECT])); tfe_http_half_append_body(response, page_buff, page_size, 0); tfe_http_half_append_body(response, NULL, 0, 0); tfe_http_session_response_set(to_write_sess, response); @@ -1622,10 +1617,7 @@ static void http_block(const struct tfe_http_session * session, enum tfe_http_ev } else { - if(ctx->enforce_rules[0].do_log > 0) - { - ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REJECT])); - } + ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REJECT])); to_write_sess = tfe_http_session_allow_write(session); tfe_http_session_kill(to_write_sess); } @@ -1685,13 +1677,10 @@ static void http_hijack(const struct tfe_http_session * session, enum tfe_http_e return; } ctx->inject_sz = hijack_size; - if(ctx->enforce_rules[0].do_log > 0) - { - ATOMIC_ADD(&(g_pangu_rt->stat_val[STAT_ACTION_HIJACK_SZ]), hijack_size); - ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_HIJACK])); - } - char cont_len_str[16]; + ATOMIC_ADD(&(g_pangu_rt->stat_val[STAT_ACTION_HIJACK_SZ]), hijack_size); + ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_HIJACK])); + char cont_len_str[16]; to_write_sess = tfe_http_session_allow_write(session); response = tfe_http_session_response_create(to_write_sess, 200); @@ -1865,11 +1854,8 @@ static void http_insert(const struct tfe_stream * stream, const struct tfe_http_ if (rewrite_sz >0) { tfe_http_half_append_body(ins_ctx->replacing, rewrite_buff, rewrite_sz, 0); - if(ctx->enforce_rules[0].do_log > 0) - { - ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_INSERT])); - ATOMIC_ADD(&(g_pangu_rt->stat_val[STAT_ACTION_INSERT_SZ]), ctx->inject_sz); - } + ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_INSERT])); + ATOMIC_ADD(&(g_pangu_rt->stat_val[STAT_ACTION_INSERT_SZ]), ctx->inject_sz); ins_ctx->actually_inserted=1; } else @@ -2524,7 +2510,7 @@ void pangu_on_http_end(const struct tfe_stream * stream, } } - if(ctx->rep_ctx && ctx->rep_ctx->actually_replaced==1 && ctx->enforce_rules[0].do_log ==1) + if(ctx->rep_ctx && ctx->rep_ctx->actually_replaced==1) { ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REPLACE])); } diff --git a/plugin/protocol/http2/src/http2_stream.cpp b/plugin/protocol/http2/src/http2_stream.cpp index e24b9c3..3d4df91 100644 --- a/plugin/protocol/http2/src/http2_stream.cpp +++ b/plugin/protocol/http2/src/http2_stream.cpp @@ -1959,6 +1959,9 @@ finish: h2_stream_info->thread_id); h2_session->frame_ctx = NULL; delete_http2_stream_data(h2_session, h2_stream_info->tf_stream, 1); + /*The stream connection is closed, Force clear context**/ + nghttp2_session_set_stream_user_data(h2_stream_info->as_client, stream_id, NULL); + nghttp2_session_set_stream_user_data(h2_stream_info->as_server, stream_id, NULL); free(h2_session); h2_session = NULL; }