]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: arg: fix error reporting for add-header/set-header sample fetch arguments
authorThierry FOURNIER <tfournier@exceliance.fr>
Wed, 20 Nov 2013 14:09:52 +0000 (15:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 28 Nov 2013 17:25:18 +0000 (18:25 +0100)
The 'add-header %[samples]' parsing errors associated to http-request
and http-response are displayed with the wrong keyword.

Configuration entry:

   http-request set-header mon-header %[res.hdr(user-agent)]

Original error message:

   [WARNING] 323/150920 (16559) : parsing [haproxy.conf:36] : 'log-format' : sample fetch <res.hdr ...

After commit error message:

   [WARNING] 323/150929 (16580) : parsing [haproxy.conf:36] : 'http-request' : sample fetch <res.hdr ...

include/types/arg.h
src/log.c
src/proto_http.c
src/sample.c

index a53d29375049d3c77580e9e7e034642dbe1cc753..9e42840443c95f1072b9004c891014714fae190c 100644 (file)
@@ -54,7 +54,8 @@ enum {
        ARGC_STK,      /* sticking rule */
        ARGC_TRK,      /* tracking rule */
        ARGC_LOG,      /* log-format */
-       ARGC_HDR,      /* add-header */
+       ARGC_HRQ,      /* http-request */
+       ARGC_HRS,      /* http-response */
        ARGC_UIF,      /* unique-id-format */
 };
 
index ae6f0a3388c0ef2ead9e8a5547a1c465149190cf..a1e5db9919b3e227907ad91e01f3d6058312cfb3 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -168,6 +168,10 @@ static inline const char *fmt_directive(const struct proxy *curproxy)
 {
        if (curproxy->conf.args.ctx == ARGC_UIF)
                return "unique-id-format";
+       else if (curproxy->conf.args.ctx == ARGC_HRQ)
+               return "http-request";
+       else if (curproxy->conf.args.ctx == ARGC_HRS)
+               return "http-response";
        else
                return "log-format";
 }
index 1921b9329871373d125c5e72daf2617a290ee397..b5ad54c84877b449b0ceaabda47ed09df298e91b 100644 (file)
@@ -8465,7 +8465,7 @@ struct http_req_rule *parse_http_req_cond(const char **args, const char *file, i
                rule->arg.hdr_add.name_len = strlen(rule->arg.hdr_add.name);
                LIST_INIT(&rule->arg.hdr_add.fmt);
 
-               proxy->conf.args.ctx = ARGC_HDR;
+               proxy->conf.args.ctx = ARGC_HRQ;
                parse_logformat_string(args[cur_arg + 1], proxy, &rule->arg.hdr_add.fmt, 0,
                                       (proxy->cap & PR_CAP_FE) ? SMP_VAL_FE_HRQ_HDR : SMP_VAL_BE_HRQ_HDR);
                cur_arg += 2;
@@ -8633,7 +8633,7 @@ struct http_res_rule *parse_http_res_cond(const char **args, const char *file, i
                rule->arg.hdr_add.name_len = strlen(rule->arg.hdr_add.name);
                LIST_INIT(&rule->arg.hdr_add.fmt);
 
-               proxy->conf.args.ctx = ARGC_HDR;
+               proxy->conf.args.ctx = ARGC_HRS;
                parse_logformat_string(args[cur_arg + 1], proxy, &rule->arg.hdr_add.fmt, 0,
                                       (proxy->cap & PR_CAP_BE) ? SMP_VAL_BE_HRS_HDR : SMP_VAL_FE_HRS_HDR);
                cur_arg += 2;
index 1a2ab478a7e2a96a7bdbfb257d26376392a29e50..dc2304a7de19b359c4e6f64afaf01e5d2be8d073 100644 (file)
@@ -839,7 +839,8 @@ int smp_resolve_args(struct proxy *p)
                case ARGC_STK:where = "in stick rule in"; break;
                case ARGC_TRK: where = "in tracking rule in"; break;
                case ARGC_LOG: where = "in log-format string in"; break;
-               case ARGC_HDR: where = "in HTTP header format string in"; break;
+               case ARGC_HRQ: where = "in http-request header format string in"; break;
+               case ARGC_HRS: where = "in http-response header format string in"; break;
                case ARGC_UIF: where = "in unique-id-format string in"; break;
                case ARGC_ACL: ctx = "ACL keyword"; break;
                }