mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-11 09:37:20 +02:00
MINOR: http-htx: Store messages of an http-errors section in a http reply array
Error messages specified in an http-errors section is now also stored in an array of http replies. So, for now, these messages are stored as a buffer and as a http reply.
This commit is contained in:
parent
1b13ecaca2
commit
de30bb7245
@ -85,6 +85,7 @@ struct http_errors {
|
|||||||
} conf; /* config information */
|
} conf; /* config information */
|
||||||
|
|
||||||
struct buffer *errmsg[HTTP_ERR_SIZE]; /* customized error messages for known errors */
|
struct buffer *errmsg[HTTP_ERR_SIZE]; /* customized error messages for known errors */
|
||||||
|
struct http_reply *replies[HTTP_ERR_SIZE]; /* HTTP replies for known errors */
|
||||||
struct list list; /* http-errors list */
|
struct list list; /* http-errors list */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1030,6 +1030,7 @@ static void http_htx_deinit(void)
|
|||||||
struct http_errors *http_errs, *http_errsb;
|
struct http_errors *http_errs, *http_errsb;
|
||||||
struct ebpt_node *node, *next;
|
struct ebpt_node *node, *next;
|
||||||
struct http_error_msg *http_errmsg;
|
struct http_error_msg *http_errmsg;
|
||||||
|
int rc;
|
||||||
|
|
||||||
node = ebpt_first(&http_error_messages);
|
node = ebpt_first(&http_error_messages);
|
||||||
while (node) {
|
while (node) {
|
||||||
@ -1045,6 +1046,8 @@ static void http_htx_deinit(void)
|
|||||||
list_for_each_entry_safe(http_errs, http_errsb, &http_errors_list, list) {
|
list_for_each_entry_safe(http_errs, http_errsb, &http_errors_list, list) {
|
||||||
free(http_errs->conf.file);
|
free(http_errs->conf.file);
|
||||||
free(http_errs->id);
|
free(http_errs->id);
|
||||||
|
for (rc = 0; rc < HTTP_ERR_SIZE; rc++)
|
||||||
|
release_http_reply(http_errs->replies[rc]);
|
||||||
LIST_DEL(&http_errs->list);
|
LIST_DEL(&http_errs->list);
|
||||||
free(http_errs);
|
free(http_errs);
|
||||||
}
|
}
|
||||||
@ -1977,6 +1980,7 @@ static int cfg_parse_http_errors(const char *file, int linenum, char **args, int
|
|||||||
curr_errs->conf.line = linenum;
|
curr_errs->conf.line = linenum;
|
||||||
}
|
}
|
||||||
else if (!strcmp(args[0], "errorfile")) { /* error message from a file */
|
else if (!strcmp(args[0], "errorfile")) { /* error message from a file */
|
||||||
|
struct http_reply *reply;
|
||||||
struct buffer *msg;
|
struct buffer *msg;
|
||||||
int status, rc;
|
int status, rc;
|
||||||
|
|
||||||
@ -1994,8 +1998,22 @@ static int cfg_parse_http_errors(const char *file, int linenum, char **args, int
|
|||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reply = calloc(1, sizeof(*reply));
|
||||||
|
if (!reply) {
|
||||||
|
ha_alert("parsing [%s:%d] : %s : out of memory.\n", file, linenum, args[0]);
|
||||||
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
reply->type = HTTP_REPLY_ERRMSG;
|
||||||
|
reply->status = status;
|
||||||
|
reply->ctype = NULL;
|
||||||
|
LIST_INIT(&reply->hdrs);
|
||||||
|
reply->body.errmsg = msg;
|
||||||
|
|
||||||
rc = http_get_status_idx(status);
|
rc = http_get_status_idx(status);
|
||||||
curr_errs->errmsg[rc] = msg;
|
curr_errs->errmsg[rc] = msg;
|
||||||
|
curr_errs->replies[rc] = reply;
|
||||||
}
|
}
|
||||||
else if (*args[0] != 0) {
|
else if (*args[0] != 0) {
|
||||||
ha_alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section\n", file, linenum, args[0], cursection);
|
ha_alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section\n", file, linenum, args[0], cursection);
|
||||||
|
Loading…
Reference in New Issue
Block a user