MEDIUM: http-htx/proxy: Use a global and centralized storage for HTTP error messages

All custom HTTP errors are now stored in a global tree. Proxies use a references
on these messages. The key used for errorfile directives is the file name as
specified in the configuration. For errorloc directives, a key is created using
the redirect code and the url. This means that the same custom error message is
now stored only once. It may be used in several proxies or for several status
code, it is only parsed and stored once.
diff --git a/include/proto/http_htx.h b/include/proto/http_htx.h
index 0cec9db..3f86340 100644
--- a/include/proto/http_htx.h
+++ b/include/proto/http_htx.h
@@ -49,9 +49,9 @@
 			       int occ, struct http_hdr_ctx *ctx, char **vptr, size_t *vlen);
 int http_str_to_htx(struct buffer *buf, struct ist raw);
 
-int http_load_errorfile(const char *file, struct buffer *buf, char **errmsg);
-int http_load_errormsg(const struct ist msg, struct buffer *buf, char **errmsg);
-int http_parse_errorfile(int status, const char *file, struct buffer *buf, char **errmsg);
-int http_parse_errorloc(int errloc, int status, const char *url, struct buffer *buf, char **errmsg);
+struct buffer *http_load_errorfile(const char *file, char **errmsg);
+struct buffer *http_load_errormsg(const char *key, const struct ist msg, char **errmsg);
+struct buffer *http_parse_errorfile(int status, const char *file, char **errmsg);
+struct buffer *http_parse_errorloc(int errloc, int status, const char *url, char **errmsg);
 
 #endif /* _PROTO_HTTP_HTX_H */
diff --git a/include/types/http_htx.h b/include/types/http_htx.h
index 3f9a7f4..d9c3052 100644
--- a/include/types/http_htx.h
+++ b/include/types/http_htx.h
@@ -23,6 +23,9 @@
 #ifndef _TYPES_HTTP_HTX_H
 #define _TYPES_HTTP_HTX_H
 
+#include <ebistree.h>
+
+#include <common/buf.h>
 #include <common/htx.h>
 #include <common/ist.h>
 
@@ -34,4 +37,12 @@
 	uint16_t       lws_after;
 };
 
+/* A custom HTTP error message load from a row file and converted in HTX. The
+ * node key is the file path.
+ */
+struct http_error {
+	struct buffer msg;
+	struct ebpt_node node;
+};
+
 #endif /* _TYPES_HTTP_HTX_H */
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 6ea96b3..232634d 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -427,7 +427,7 @@
 	char *check_path;			/* PATH environment to use for external agent checks */
 	char *expect_str;			/* http-check expected content : string or text version of the regex */
 	struct my_regex *expect_regex;		/* http-check expected content */
-	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 */
 	int uuid;				/* universally unique proxy ID, used for SNMP */
 	unsigned int backlog;			/* force the frontend's listen backlog */
 	unsigned long bind_proc;		/* bitmask of processes using this proxy */