不cache包含Set-cookie的应答。修改多处日志细节。

This commit is contained in:
zhengchao
2018-10-21 15:03:04 +08:00
parent c94b267a65
commit c5f5ee2655
8 changed files with 36 additions and 9 deletions

View File

@@ -60,6 +60,7 @@ enum pangu_http_stat
STAT_ACTION_MONIT,
STAT_ACTION_REJECT,
STAT_ACTION_REDIRECT,
STAT_ACTION_PRE_REPLACE,
STAT_ACTION_REPLACE,
STAT_ACTION_WHITELSIT,
__PG_STAT_MAX
@@ -185,9 +186,10 @@ static void pangu_http_stat_init(struct pangu_rt * pangu_runtime)
const char* spec[__PG_STAT_MAX]={0};
spec[STAT_SESSION]="http_sess";
spec[STAT_LOG_NUM]="log_num";
spec[STAT_ACTION_MONIT]="monit";
spec[STAT_ACTION_MONIT]="monitor";
spec[STAT_ACTION_REJECT]="reject";
spec[STAT_ACTION_REDIRECT]="redirect";
spec[STAT_ACTION_PRE_REPLACE]="pre_replace";
spec[STAT_ACTION_REPLACE]="replace";
spec[STAT_ACTION_WHITELSIT]="whitelist";
@@ -291,6 +293,7 @@ struct replace_ctx
struct pangu_http_ctx
{
int magic_num;
enum pangu_action action;
char * action_para;
scan_status_t mid;
@@ -329,9 +332,11 @@ void http_repl_ctx_free(struct replace_ctx* rep_ctx)
FREE(&rep_ctx);
return;
}
#define HTTP_CTX_MAGIC_NUM 20181021
static struct pangu_http_ctx * pangu_http_ctx_new(unsigned int thread_id)
{
struct pangu_http_ctx * ctx = ALLOC(struct pangu_http_ctx, 1);
ctx->magic_num=HTTP_CTX_MAGIC_NUM;
ctx->mid = NULL;
ctx->thread_id = (int) thread_id;
return ctx;
@@ -339,6 +344,7 @@ static struct pangu_http_ctx * pangu_http_ctx_new(unsigned int thread_id)
static void pangu_http_ctx_free(struct pangu_http_ctx * ctx)
{
assert(ctx->magic_num==HTTP_CTX_MAGIC_NUM);
if (ctx->rep_ctx)
{
http_repl_ctx_free(ctx->rep_ctx);
@@ -365,6 +371,7 @@ static void pangu_http_ctx_free(struct pangu_http_ctx * ctx)
future_destroy(ctx->f_cache_query);
ctx->f_cache_query=NULL;
}
ctx->magic_num=0;
FREE(&ctx);
}
@@ -912,7 +919,7 @@ void enforce_control_policy(const struct tfe_stream * stream, const struct tfe_h
break;
case PG_ACTION_REPLACE:
http_replace(stream, session, events, body_frag, frag_size, ctx);
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REPLACE]));
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_PRE_REPLACE]));
break;
case PG_ACTION_WHITELIST:
tfe_http_session_detach(session);
@@ -1018,6 +1025,10 @@ void pangu_on_http_end(const struct tfe_stream * stream,
ret=pangu_send_log(g_pangu_rt->send_logger, &log_msg);
ATOMIC_ADD(&(g_pangu_rt->stat_val[STAT_LOG_NUM]), ret);
}
if(ctx->rep_ctx && ctx->rep_ctx->actually_replaced==0)
{
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REPLACE]));
}
pangu_http_ctx_free(ctx);
*pme = NULL;
return;