MINOR: http: Don't store raw HTTP errors in chunks anymore

Default HTTP error messages are stored in an array of chunks. And since the HTX
was added, these messages are also converted in HTX and stored in another
array. But now, the first array is not used anymore because the legacy HTTP mode
was removed.

So now, only the array with the HTX messages are kept. The other one was
removed.
diff --git a/include/common/http.h b/include/common/http.h
index b0befa5..537be5a 100644
--- a/include/common/http.h
+++ b/include/common/http.h
@@ -120,7 +120,6 @@
 
 extern const int http_err_codes[HTTP_ERR_SIZE];
 extern const char *http_err_msgs[HTTP_ERR_SIZE];
-extern struct buffer http_err_chunks[HTTP_ERR_SIZE];
 extern const struct ist http_known_methods[HTTP_METH_OTHER];
 extern const uint8_t http_char_classes[256];
 
@@ -134,7 +133,6 @@
 extern const char *HTTP_401_fmt;
 extern const char *HTTP_407_fmt;
 
-int init_http(char **err);
 enum http_meth_t find_http_meth(const char *str, const int len);
 int http_get_status_idx(unsigned int status);
 const char *http_get_reason(unsigned int status);
diff --git a/include/proto/http_htx.h b/include/proto/http_htx.h
index a134052..e33fdbe 100644
--- a/include/proto/http_htx.h
+++ b/include/proto/http_htx.h
@@ -28,7 +28,7 @@
 
 #include <types/http_htx.h>
 
-extern struct buffer htx_err_chunks[HTTP_ERR_SIZE];
+extern struct buffer http_err_chunks[HTTP_ERR_SIZE];
 
 struct htx_sl *http_get_stline(struct htx *htx);
 int http_find_header(const struct htx *htx, const struct ist name, struct http_hdr_ctx *ctx, int full);
@@ -47,5 +47,6 @@
 			      int occ, struct http_hdr_ctx *ctx, char **vptr, size_t *vlen);
 unsigned int http_get_htx_fhdr(const struct htx *htx, const struct ist hdr,
 			       int occ, struct http_hdr_ctx *ctx, char **vptr, size_t *vlen);
+struct htx *http_str_to_htx(struct buffer *buf, struct ist raw);
 
 #endif /* _PROTO_HTTP_HTX_H */
diff --git a/src/cache.c b/src/cache.c
index ccbbe52..9cef0ca 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -963,7 +963,7 @@
   error:
 	/* Sent and HTTP error 500 */
 	b_reset(&res->buf);
-	errmsg = &htx_err_chunks[HTTP_ERR_500];
+	errmsg = &http_err_chunks[HTTP_ERR_500];
 	res->buf.data = b_data(errmsg);
 	memcpy(res->buf.area, b_head(errmsg), b_data(errmsg));
 	res_htx = htx_from_buf(&res->buf);
diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c
index 1101a98..cf3cb56 100644
--- a/src/cfgparse-listen.c
+++ b/src/cfgparse-listen.c
@@ -20,6 +20,7 @@
 #include <proto/acl.h>
 #include <proto/checks.h>
 #include <proto/connection.h>
+#include <proto/http_htx.h>
 #include <proto/http_rules.h>
 #include <proto/listener.h>
 #include <proto/protocol.h>
@@ -3832,8 +3833,17 @@
 
 		for (rc = 0; rc < HTTP_ERR_SIZE; rc++) {
 			if (http_err_codes[rc] == errnum) {
+				struct buffer chk;
+
+				if (!http_str_to_htx(&chk, ist2(err, errlen))) {
+					ha_alert("parsing [%s:%d] : unable to convert message in HTX for HTTP return code %d.\n",
+						 file, linenum, http_err_codes[rc]);
+					err_code |= ERR_ALERT | ERR_FATAL;
+					free(err);
+					goto out;
+				}
 				chunk_destroy(&curproxy->errmsg[rc]);
-				chunk_initlen(&curproxy->errmsg[rc], err, errlen, errlen);
+				curproxy->errmsg[rc] = chk;
 				break;
 			}
 		}
@@ -3892,8 +3902,17 @@
 		errnum = atol(args[1]);
 		for (rc = 0; rc < HTTP_ERR_SIZE; rc++) {
 			if (http_err_codes[rc] == errnum) {
+				struct buffer chk;
+
+				if (!http_str_to_htx(&chk, ist2(err, errlen))) {
+					ha_alert("parsing [%s:%d] : unable to convert message in HTX for HTTP return code %d.\n",
+						 file, linenum, http_err_codes[rc]);
+					err_code |= ERR_ALERT | ERR_FATAL;
+					free(err);
+					goto out;
+				}
 				chunk_destroy(&curproxy->errmsg[rc]);
-				chunk_initlen(&curproxy->errmsg[rc], err, errlen, errlen);
+				curproxy->errmsg[rc] = chk;
 				break;
 			}
 		}
diff --git a/src/haproxy.c b/src/haproxy.c
index 2525613..dfd2819 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -1383,13 +1383,6 @@
 	if (init_acl() != 0)
 		exit(1);
 
-	/* warning, we init buffers later */
-	if (!init_http(&err_msg)) {
-		ha_alert("%s. Aborting.\n", err_msg);
-		free(err_msg);
-		abort();
-	}
-
 	/* Initialise lua. */
 	hlua_init();
 
diff --git a/src/hlua.c b/src/hlua.c
index aca3cc9..fe67f04 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -6724,7 +6724,7 @@
 	 * just close the connection.
 	 */
 	if (!(ctx->ctx.hlua_apphttp.flags & APPLET_HDR_SENT)) {
-		struct buffer *err = &htx_err_chunks[HTTP_ERR_500];
+		struct buffer *err = &http_err_chunks[HTTP_ERR_500];
 
 		channel_erase(res);
 		res->buf.data = b_data(err);
diff --git a/src/http.c b/src/http.c
index 66a4282..c77f8c8 100644
--- a/src/http.c
+++ b/src/http.c
@@ -155,11 +155,6 @@
 	[127] = HTTP_FLG_CTL,
 };
 
-/* We must put the messages here since GCC cannot initialize consts depending
- * on strlen().
- */
-struct buffer http_err_chunks[HTTP_ERR_SIZE];
-
 const struct ist HTTP_100 = IST("HTTP/1.1 100 Continue\r\n\r\n");
 
 const struct ist HTTP_103 = IST("HTTP/1.1 103 Early Hints\r\n");
@@ -985,23 +980,3 @@
 
         return 1;
 }
-
-
-/* post-initializes the HTTP parts. Returns zero on error, with <err>
- * pointing to the error message.
- */
-int init_http(char **err)
-{
-	int msg;
-
-	for (msg = 0; msg < HTTP_ERR_SIZE; msg++) {
-		if (!http_err_msgs[msg]) {
-			memprintf(err, "Internal error: no message defined for HTTP return code %d", msg);
-			return 0;
-		}
-
-		http_err_chunks[msg].area = (char *)http_err_msgs[msg];
-		http_err_chunks[msg].data = strlen(http_err_msgs[msg]);
-	}
-	return 1;
-}
diff --git a/src/http_ana.c b/src/http_ana.c
index 9e876cd..ac3412b 100644
--- a/src/http_ana.c
+++ b/src/http_ana.c
@@ -4904,7 +4904,7 @@
 	else if (strm_fe(s)->errmsg[msgnum].area)
 		return &strm_fe(s)->errmsg[msgnum];
 	else
-		return &htx_err_chunks[msgnum];
+		return &http_err_chunks[msgnum];
 }
 
 /* Return the error message corresponding to si->err_type. It is assumed
diff --git a/src/http_htx.c b/src/http_htx.c
index 3382811..07ff191 100644
--- a/src/http_htx.c
+++ b/src/http_htx.c
@@ -19,7 +19,7 @@
 
 #include <proto/http_htx.h>
 
-struct buffer htx_err_chunks[HTTP_ERR_SIZE];
+struct buffer http_err_chunks[HTTP_ERR_SIZE];
 
 /* Returns the next unporocessed start line in the HTX message. It returns NULL
  * if the start-line is undefined (first == -1). Otherwise, it returns the
@@ -600,7 +600,7 @@
 	return 1;
 }
 
-static struct htx *http_str_to_htx(struct buffer *buf, struct ist raw)
+struct htx *http_str_to_htx(struct buffer *buf, struct ist raw)
 {
 	struct htx *htx;
 	struct htx_sl *sl;
@@ -673,28 +673,11 @@
 
 static int http_htx_init(void)
 {
-	struct proxy *px;
 	struct buffer chk;
 	struct ist raw;
 	int rc;
 	int err_code = 0;
 
-	for (px = proxies_list; px; px = px->next) {
-		for (rc = 0; rc < HTTP_ERR_SIZE; rc++) {
-			if (!b_data(&px->errmsg[rc]))
-				continue;
-
-			raw = ist2(b_head(&px->errmsg[rc]), b_data(&px->errmsg[rc]));
-			if (!http_str_to_htx(&chk, raw)) {
-				ha_alert("config: %s '%s': Unable to convert message in HTX for HTTP return code %d.\n",
-					 proxy_type_str(px), px->id, http_err_codes[rc]);
-				err_code |= ERR_ALERT | ERR_FATAL;
-			}
-			chunk_destroy(&px->errmsg[rc]);
-			px->errmsg[rc] = chk;
-		}
-	}
-
 	for (rc = 0; rc < HTTP_ERR_SIZE; rc++) {
 		if (!http_err_msgs[rc]) {
 			ha_alert("Internal error: no message defined for HTTP return code %d", rc);
@@ -708,7 +691,7 @@
 				 http_err_codes[rc]);
 			err_code |= ERR_ALERT | ERR_FATAL;
 		}
-		htx_err_chunks[rc] = chk;
+		http_err_chunks[rc] = chk;
 	}
 end:
 	return err_code;