MINOR: proxy: Add references on http replies for proxy error messages

Error messages defined in proxy section or inherited from a default section are
now also referenced using an array of http replies. This is done during the
configuration validity check.
This commit is contained in:
Christopher Faulet 2020-05-14 17:34:31 +02:00
parent 5809e10b48
commit 40e8569676
2 changed files with 6 additions and 1 deletions

View File

@ -409,6 +409,7 @@ struct proxy {
char *check_command; /* Command to use for external agent checks */ char *check_command; /* Command to use for external agent checks */
char *check_path; /* PATH environment to use for external agent checks */ char *check_path; /* PATH environment to use for external agent checks */
struct buffer *errmsg[HTTP_ERR_SIZE]; /* default or customized error messages for known errors */ struct buffer *errmsg[HTTP_ERR_SIZE]; /* default or customized error messages for known errors */
struct http_reply *replies[HTTP_ERR_SIZE]; /* HTTP replies for known errors */
int uuid; /* universally unique proxy ID, used for SNMP */ int uuid; /* universally unique proxy ID, used for SNMP */
unsigned int backlog; /* force the frontend's listen backlog */ unsigned int backlog; /* force the frontend's listen backlog */
unsigned long bind_proc; /* bitmask of processes using this proxy */ unsigned long bind_proc; /* bitmask of processes using this proxy */

View File

@ -1852,6 +1852,7 @@ static int proxy_check_errors(struct proxy *px)
/* errorfile */ /* errorfile */
rc = http_get_status_idx(conf_err->info.errorfile.status); rc = http_get_status_idx(conf_err->info.errorfile.status);
px->errmsg[rc] = conf_err->info.errorfile.msg; px->errmsg[rc] = conf_err->info.errorfile.msg;
px->replies[rc] = conf_err->info.errorfile.reply;
} }
else { else {
/* errorfiles */ /* errorfiles */
@ -1872,8 +1873,10 @@ static int proxy_check_errors(struct proxy *px)
free(conf_err->info.errorfiles.name); free(conf_err->info.errorfiles.name);
for (rc = 0; rc < HTTP_ERR_SIZE; rc++) { for (rc = 0; rc < HTTP_ERR_SIZE; rc++) {
if (conf_err->info.errorfiles.status[rc] > 0) { if (conf_err->info.errorfiles.status[rc] > 0) {
if (http_errs->errmsg[rc]) if (http_errs->errmsg[rc]) {
px->errmsg[rc] = http_errs->errmsg[rc]; px->errmsg[rc] = http_errs->errmsg[rc];
px->replies[rc] = http_errs->replies[rc];
}
else if (conf_err->info.errorfiles.status[rc] == 2) else if (conf_err->info.errorfiles.status[rc] == 2)
ha_warning("config: proxy '%s' : status '%d' not declared in" ha_warning("config: proxy '%s' : status '%d' not declared in"
" http-errors section '%s' (at %s:%d).\n", " http-errors section '%s' (at %s:%d).\n",
@ -1934,6 +1937,7 @@ int proxy_dup_default_conf_errors(struct proxy *curpx, struct proxy *defpx, char
if (conf_err->type == 1) { if (conf_err->type == 1) {
new_conf_err->info.errorfile.status = conf_err->info.errorfile.status; new_conf_err->info.errorfile.status = conf_err->info.errorfile.status;
new_conf_err->info.errorfile.msg = conf_err->info.errorfile.msg; new_conf_err->info.errorfile.msg = conf_err->info.errorfile.msg;
new_conf_err->info.errorfile.reply = conf_err->info.errorfile.reply;
} }
else { else {
new_conf_err->info.errorfiles.name = strdup(conf_err->info.errorfiles.name); new_conf_err->info.errorfiles.name = strdup(conf_err->info.errorfiles.name);