MINOR: http-htx: Store errorloc/errorfile messages in http replies

During configuration parsing, error messages resulting of parsing of errorloc
and errorfile directives are now also stored as an http reply. So, for now,
these messages are stored as a buffer and as an http reply. To be able to
release all these http replies when haproxy is stopped, a global list is
used. We must do that because the same http reply may be referenced several
times by different proxies if it is defined in a default section.
diff --git a/src/http_htx.c b/src/http_htx.c
index 7c90a96..b830c73 100644
--- a/src/http_htx.c
+++ b/src/http_htx.c
@@ -33,6 +33,7 @@
 
 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. */
@@ -42,6 +43,7 @@
 		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 */
@@ -1028,6 +1030,7 @@
 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;
@@ -1051,6 +1054,11 @@
 		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);
@@ -1647,6 +1655,7 @@
 				  char **errmsg)
 {
 	struct conf_errors *conf_err;
+	struct http_reply *reply;
 	struct buffer *msg;
 	int errloc, status;
 	int ret = 0;
@@ -1670,16 +1679,32 @@
 		ret = -1;
 		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);
@@ -1695,6 +1720,7 @@
 				 char **errmsg)
 {
 	struct conf_errors *conf_err;
+	struct http_reply *reply;
 	struct buffer *msg;
 	int status;
 	int ret = 0;
@@ -1718,15 +1744,30 @@
 		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);