http response body位置命中阻断规则时,不调用tfe_http_session_allow_write。
This commit is contained in:
@@ -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);
|
||||
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);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user