MINOR: http-htx: Store default error messages in a global http reply array

Default error messages are stored as a buffer, in http_err_chunks global array.
Now, they are also stored as a http reply, in http_err_replies global array.
This commit is contained in:
Christopher Faulet 2020-05-14 09:54:26 +02:00
parent 5cb513abeb
commit 1b13ecaca2
2 changed files with 8 additions and 0 deletions

View File

@ -30,6 +30,7 @@
#include <types/http_htx.h> #include <types/http_htx.h>
extern struct buffer http_err_chunks[HTTP_ERR_SIZE]; extern struct buffer http_err_chunks[HTTP_ERR_SIZE];
extern struct http_reply http_err_replies[HTTP_ERR_SIZE];
extern struct list http_errors_list; extern struct list http_errors_list;
struct htx_sl *http_get_stline(struct htx *htx); struct htx_sl *http_get_stline(struct htx *htx);

View File

@ -29,6 +29,8 @@
#include <proto/sample.h> #include <proto/sample.h>
struct buffer http_err_chunks[HTTP_ERR_SIZE]; struct buffer http_err_chunks[HTTP_ERR_SIZE];
struct http_reply http_err_replies[HTTP_ERR_SIZE];
struct eb_root http_error_messages = EB_ROOT; struct eb_root http_error_messages = EB_ROOT;
struct list http_errors_list = LIST_HEAD_INIT(http_errors_list); struct list http_errors_list = LIST_HEAD_INIT(http_errors_list);
@ -1013,6 +1015,11 @@ static int http_htx_init(void)
err_code |= ERR_ALERT | ERR_FATAL; err_code |= ERR_ALERT | ERR_FATAL;
} }
http_err_chunks[rc] = chk; http_err_chunks[rc] = chk;
http_err_replies[rc].type = HTTP_REPLY_ERRMSG;
http_err_replies[rc].status = http_err_codes[rc];
http_err_replies[rc].ctype = NULL;
LIST_INIT(&http_err_replies[rc].hdrs);
http_err_replies[rc].body.errmsg = &http_err_chunks[rc];
} }
end: end:
return err_code; return err_code;