mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-17 12:35:37 +00:00
BUG/MINOR: config: correctly report when log-format headers require HTTP mode
When using some log-format directives in header insertion without HTTP mode, the config parser used to report a cryptic message about option httplog being downgraded to tcplog and with "(null):0" as the file name and line number. This is because the lfs_file and lfs_line were not properly set for some valid use cases of log-format directives. Now we cover http-request and http-response as well.
This commit is contained in:
parent
4efb353e47
commit
59ad1a2e75
@ -8383,6 +8383,9 @@ struct http_req_rule *parse_http_req_cond(const char **args, const char *file, i
|
||||
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);
|
||||
free(proxy->conf.lfs_file);
|
||||
proxy->conf.lfs_file = strdup(proxy->conf.args.file);
|
||||
proxy->conf.lfs_line = proxy->conf.args.line;
|
||||
cur_arg += 2;
|
||||
} else if (strcmp(args[0], "redirect") == 0) {
|
||||
struct redirect_rule *redir;
|
||||
@ -8551,6 +8554,9 @@ struct http_res_rule *parse_http_res_cond(const char **args, const char *file, i
|
||||
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);
|
||||
free(proxy->conf.lfs_file);
|
||||
proxy->conf.lfs_file = strdup(proxy->conf.args.file);
|
||||
proxy->conf.lfs_line = proxy->conf.args.line;
|
||||
cur_arg += 2;
|
||||
} else {
|
||||
Alert("parsing [%s:%d]: 'http-response' expects 'allow', 'deny', 'redirect', 'add-header', 'set-header', 'set-nice', 'set-tos', 'set-mark', 'set-log-level', but got '%s'%s.\n",
|
||||
@ -8704,6 +8710,9 @@ struct redirect_rule *http_parse_redirect_rule(const char *file, int linenum, st
|
||||
if (!(type == REDIRECT_TYPE_PREFIX && destination[0] == '/' && destination[1] == '\0')) {
|
||||
parse_logformat_string(destination, curproxy, &rule->rdr_fmt, 0,
|
||||
(curproxy->cap & PR_CAP_FE) ? SMP_VAL_FE_HRQ_HDR : SMP_VAL_BE_HRQ_HDR);
|
||||
free(curproxy->conf.lfs_file);
|
||||
curproxy->conf.lfs_file = strdup(curproxy->conf.args.file);
|
||||
curproxy->conf.lfs_line = curproxy->conf.args.line;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,7 @@ int proxy_cfg_ensure_no_http(struct proxy *curproxy)
|
||||
}
|
||||
if (curproxy->to_log & (LW_REQ | LW_RESP)) {
|
||||
curproxy->to_log &= ~(LW_REQ | LW_RESP);
|
||||
Warning("parsing [%s:%d] : 'option httplog' not usable with %s '%s' (needs 'mode http'). Falling back to 'option tcplog'.\n",
|
||||
Warning("parsing [%s:%d] : HTTP log/header format not usable with %s '%s' (needs 'mode http').\n",
|
||||
curproxy->conf.lfs_file, curproxy->conf.lfs_line,
|
||||
proxy_type_str(curproxy), curproxy->id);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user