From: Frédéric Lécaille Date: Tue, 6 Nov 2018 13:30:19 +0000 (+0100) Subject: MINOR: http: Make new "early-hint" http-request action really be parsed. X-Git-Tag: v1.9-dev7~130 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ebbcb663cef7755dca746d5de84ee2c251a3033;p=thirdparty%2Fhaproxy.git MINOR: http: Make new "early-hint" http-request action really be parsed. This patch adds a "early_hint" struct to "arg" union of "act_rule" struct and parse "early-hint" http-request keyword with it using the same code as for "(add|set)-header" parser. --- diff --git a/include/types/action.h b/include/types/action.h index b24ce21e62..0367ea9f55 100644 --- a/include/types/action.h +++ b/include/types/action.h @@ -116,6 +116,11 @@ struct act_rule { struct list fmt; /* log-format compatible expression */ struct my_regex re; /* used by replace-header and replace-value */ } hdr_add; /* args used by "add-header" and "set-header" */ + struct { + char *name; /* header name */ + int name_len; /* header name's length */ + struct list fmt; /* log-format compatible expression */ + } early_hint; struct redirect_rule *redir; /* redirect rule or "http-request redirect" */ int nice; /* nice value for ACT_HTTP_SET_NICE */ int loglevel; /* log-level value for ACT_HTTP_SET_LOGL */ diff --git a/src/http_rules.c b/src/http_rules.c index 87117bf943..c7b5a71e71 100644 --- a/src/http_rules.c +++ b/src/http_rules.c @@ -210,8 +210,17 @@ struct act_rule *parse_http_req_cond(const char **args, const char *file, int li cur_arg++; } else if (strcmp(args[0], "add-header") == 0 || strcmp(args[0], "set-header") == 0 || strcmp(args[0], "early-hint") == 0) { + char **hdr_name; + int *hdr_name_len; + struct list *fmt; + rule->action = *args[0] == 'a' ? ACT_HTTP_ADD_HDR : *args[0] == 's' ? ACT_HTTP_SET_HDR : ACT_HTTP_EARLY_HINT; + + hdr_name = *args[0] == 'e' ? &rule->arg.early_hint.name : &rule->arg.hdr_add.name; + hdr_name_len = *args[0] == 'e' ? &rule->arg.early_hint.name_len : &rule->arg.hdr_add.name_len; + fmt = *args[0] == 'e' ? &rule->arg.early_hint.fmt : &rule->arg.hdr_add.fmt; + cur_arg = 1; if (!*args[cur_arg] || !*args[cur_arg+1] || @@ -221,13 +230,13 @@ struct act_rule *parse_http_req_cond(const char **args, const char *file, int li goto out_err; } - rule->arg.hdr_add.name = strdup(args[cur_arg]); - rule->arg.hdr_add.name_len = strlen(rule->arg.hdr_add.name); - LIST_INIT(&rule->arg.hdr_add.fmt); + *hdr_name = strdup(args[cur_arg]); + *hdr_name_len = strlen(*hdr_name); + LIST_INIT(fmt); proxy->conf.args.ctx = ARGC_HRQ; error = NULL; - if (!parse_logformat_string(args[cur_arg + 1], proxy, &rule->arg.hdr_add.fmt, LOG_OPT_HTTP, + if (!parse_logformat_string(args[cur_arg + 1], proxy, fmt, LOG_OPT_HTTP, (proxy->cap & PR_CAP_FE) ? SMP_VAL_FE_HRQ_HDR : SMP_VAL_BE_HRQ_HDR, &error)) { ha_alert("parsing [%s:%d]: 'http-request %s': %s.\n", file, linenum, args[0], error);