]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http: Make new "early-hint" http-request action really be parsed.
authorFrédéric Lécaille <flecaille@haproxy.com>
Tue, 6 Nov 2018 13:30:19 +0000 (14:30 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 12 Nov 2018 20:08:55 +0000 (21:08 +0100)
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.

include/types/action.h
src/http_rules.c

index b24ce21e6256af7721e2225f845d450c7aa0e2f9..0367ea9f55edf0576df4d58d6255d14c62580032 100644 (file)
@@ -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 */
index 87117bf94334c156d4a580ad225e721578b9285d..c7b5a71e71740c4b3430f39465f57731e8291e97 100644 (file)
@@ -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);