修改hijack,当未定义文件名时,读取Content-Disposition值初始化文件名
This commit is contained in:
@@ -1647,8 +1647,9 @@ static void http_hijack(const struct tfe_http_session * session, enum tfe_http_e
|
|||||||
{
|
{
|
||||||
struct policy_action_param *param = ctx->param;
|
struct policy_action_param *param = ctx->param;
|
||||||
struct tfe_http_half * response = NULL;
|
struct tfe_http_half * response = NULL;
|
||||||
|
struct tfe_http_session * to_write_sess = NULL;
|
||||||
|
|
||||||
if (param->profile_id <= 0 || !(events & EV_HTTP_RESP_HDR || tfe_http_in_request(events)))
|
if (param->profile_id <= 0)
|
||||||
{
|
{
|
||||||
TFE_LOG_ERROR(g_pangu_rt->local_logger, "Invalid hijack rule %d",
|
TFE_LOG_ERROR(g_pangu_rt->local_logger, "Invalid hijack rule %d",
|
||||||
ctx->enforce_rules[0].config_id);
|
ctx->enforce_rules[0].config_id);
|
||||||
@@ -1656,6 +1657,13 @@ static void http_hijack(const struct tfe_http_session * session, enum tfe_http_e
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tfe_http_in_request(events))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(events & EV_HTTP_RESP_HDR)
|
||||||
|
{
|
||||||
struct manipulate_profile* hijack_profile=get_profile_by_id(POLICY_PROFILE_TABLE_HIJACK, param->profile_id);
|
struct manipulate_profile* hijack_profile=get_profile_by_id(POLICY_PROFILE_TABLE_HIJACK, param->profile_id);
|
||||||
if (NULL == hijack_profile)
|
if (NULL == hijack_profile)
|
||||||
{
|
{
|
||||||
@@ -1673,7 +1681,6 @@ static void http_hijack(const struct tfe_http_session * session, enum tfe_http_e
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tfe_http_session * to_write_sess = NULL;
|
|
||||||
char cont_len_str[16];
|
char cont_len_str[16];
|
||||||
|
|
||||||
to_write_sess = tfe_http_session_allow_write(session);
|
to_write_sess = tfe_http_session_allow_write(session);
|
||||||
@@ -1687,7 +1694,11 @@ static void http_hijack(const struct tfe_http_session * session, enum tfe_http_e
|
|||||||
tfe_http_nonstd_field_write(response, "Content-Disposition", hijack_file_name);
|
tfe_http_nonstd_field_write(response, "Content-Disposition", hijack_file_name);
|
||||||
FREE(&hijack_file_name);
|
FREE(&hijack_file_name);
|
||||||
}
|
}
|
||||||
|
const char* cont_disposition_val=tfe_http_std_field_read(to_write_sess->resp, TFE_HTTP_CONT_DISPOSITION);
|
||||||
|
if (cont_disposition_val != NULL)
|
||||||
|
{
|
||||||
|
tfe_http_std_field_write(response, TFE_HTTP_CONT_DISPOSITION, cont_disposition_val);
|
||||||
|
}
|
||||||
tfe_http_std_field_write(response, TFE_HTTP_CONT_TYPE, hijack_profile->profile_type);
|
tfe_http_std_field_write(response, TFE_HTTP_CONT_TYPE, hijack_profile->profile_type);
|
||||||
snprintf(cont_len_str, sizeof(cont_len_str), "%lu", hijack_size);
|
snprintf(cont_len_str, sizeof(cont_len_str), "%lu", hijack_size);
|
||||||
tfe_http_std_field_write(response, TFE_HTTP_CONT_LENGTH, cont_len_str);
|
tfe_http_std_field_write(response, TFE_HTTP_CONT_LENGTH, cont_len_str);
|
||||||
@@ -1698,6 +1709,12 @@ static void http_hijack(const struct tfe_http_session * session, enum tfe_http_e
|
|||||||
tfe_http_session_detach(session);
|
tfe_http_session_detach(session);
|
||||||
ma_profile_table_free(hijack_profile);
|
ma_profile_table_free(hijack_profile);
|
||||||
hijack_profile = NULL;
|
hijack_profile = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
to_write_sess = tfe_http_session_allow_write(session);
|
||||||
|
tfe_http_session_kill(to_write_sess);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user