struct eb_root http_error_messages = EB_ROOT;
struct list http_errors_list = LIST_HEAD_INIT(http_errors_list);
+struct list http_replies_list = LIST_HEAD_INIT(http_replies_list);
/* The declaration of an errorfiles/errorfile directives. Used during config
* parsing only. */
struct {
int status; /* the status code associated to this error */
struct buffer *msg; /* the HTX error message */
+ struct http_reply *reply; /* the http reply for the errorfile */
} errorfile; /* describe an "errorfile" directive */
struct {
char *name; /* the http-errors section name */
static void http_htx_deinit(void)
{
struct http_errors *http_errs, *http_errsb;
+ struct http_reply *http_rep, *http_repb;
struct ebpt_node *node, *next;
struct http_error_msg *http_errmsg;
int rc;
LIST_DEL(&http_errs->list);
free(http_errs);
}
+
+ list_for_each_entry_safe(http_rep, http_repb, &http_replies_list, list) {
+ LIST_DEL(&http_rep->list);
+ release_http_reply(http_rep);
+ }
}
REGISTER_CONFIG_POSTPARSER("http_htx", http_htx_init);
char **errmsg)
{
struct conf_errors *conf_err;
+ struct http_reply *reply;
struct buffer *msg;
int errloc, status;
int ret = 0;
goto out;
}
+ reply = calloc(1, sizeof(*reply));
+ if (!reply) {
+ memprintf(errmsg, "%s : out of memory.", args[0]);
+ ret = -1;
+ goto out;
+ }
+ reply->type = HTTP_REPLY_ERRMSG;
+ reply->status = status;
+ reply->ctype = NULL;
+ LIST_INIT(&reply->hdrs);
+ reply->body.errmsg = msg;
+ LIST_ADDQ(&http_replies_list, &reply->list);
+
conf_err = calloc(1, sizeof(*conf_err));
if (!conf_err) {
memprintf(errmsg, "%s : out of memory.", args[0]);
+ free(reply);
ret = -1;
goto out;
}
conf_err->type = 1;
conf_err->info.errorfile.status = status;
conf_err->info.errorfile.msg = msg;
+ conf_err->info.errorfile.reply = reply;
+
conf_err->file = strdup(file);
conf_err->line = line;
LIST_ADDQ(&curpx->conf.errors, &conf_err->list);
char **errmsg)
{
struct conf_errors *conf_err;
+ struct http_reply *reply;
struct buffer *msg;
int status;
int ret = 0;
goto out;
}
+ reply = calloc(1, sizeof(*reply));
+ if (!reply) {
+ memprintf(errmsg, "%s : out of memory.", args[0]);
+ ret = -1;
+ goto out;
+ }
+ reply->type = HTTP_REPLY_ERRMSG;
+ reply->status = status;
+ reply->ctype = NULL;
+ LIST_INIT(&reply->hdrs);
+ reply->body.errmsg = msg;
+ LIST_ADDQ(&http_replies_list, &reply->list);
+
conf_err = calloc(1, sizeof(*conf_err));
if (!conf_err) {
memprintf(errmsg, "%s : out of memory.", args[0]);
+ free(reply);
ret = -1;
goto out;
}
conf_err->type = 1;
conf_err->info.errorfile.status = status;
conf_err->info.errorfile.msg = msg;
+ conf_err->info.errorfile.reply = reply;
conf_err->file = strdup(file);
conf_err->line = line;
LIST_ADDQ(&curpx->conf.errors, &conf_err->list);