summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhengchao <[email protected]>2018-12-09 20:31:04 +0600
committerluqiuwen <[email protected]>2018-12-12 15:01:18 +0600
commit5ebceac0c061754d22841c68a3ae296b972c8b88 (patch)
tree843cd4c4949ff61de1be80477093b1aca7f73645
parent76f0efe3cb10d59898a80283f5cfe4079da3e76a (diff)
http response body位置命中阻断规则时,不调用tfe_http_session_allow_write。
-rw-r--r--plugin/business/pangu-http/src/pangu_http.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/plugin/business/pangu-http/src/pangu_http.cpp b/plugin/business/pangu-http/src/pangu_http.cpp
index 775cfcb..bdf54ed 100644
--- a/plugin/business/pangu-http/src/pangu_http.cpp
+++ b/plugin/business/pangu-http/src/pangu_http.cpp
@@ -863,24 +863,30 @@ static void http_reject(const struct tfe_http_session * session, enum tfe_http_e
ctx->enforce_rules[0].config_id, ctx->enforce_para);
ctx->action = PG_ACTION_NONE;
- goto error_out;
+ return;
}
- to_write_sess = tfe_http_session_allow_write(session);
- response = tfe_http_session_response_create(to_write_sess, resp_code);
-
- html_generate(resp_code, ctx->enforce_rules[0].config_id, msg, &page_buff, &page_size);
- tfe_http_std_field_write(response, TFE_HTTP_CONT_TYPE, "text/html; charset=utf-8");
- 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(events & EV_HTTP_RESP_HDR || tfe_http_in_request(events))
+ {
+ to_write_sess = tfe_http_session_allow_write(session);
+ response = tfe_http_session_response_create(to_write_sess, resp_code);
- 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);
- tfe_http_session_detach(session);
+ html_generate(resp_code, ctx->enforce_rules[0].config_id, msg, &page_buff, &page_size);
+ tfe_http_std_field_write(response, TFE_HTTP_CONT_TYPE, "text/html; charset=utf-8");
+ snprintf(cont_len_str, sizeof(cont_len_str), "%lu", page_size);
+ tfe_http_std_field_write(response, TFE_HTTP_CONT_LENGTH, cont_len_str);
-error_out:
- html_free(&page_buff);
+ 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);
+ tfe_http_session_detach(session);
+ html_free(&page_buff);
+ }
+ else
+ {
+ //TODO: close http session.
+ }
+ return;
}
static void http_redirect(const struct tfe_http_session * session, enum tfe_http_event events,