MINOR: proxy: Make header_unique_id a struct ist

The `header_unique_id` member of `struct proxy` now is a `struct ist`.
This commit is contained in:
Tim Duesterhus 2020-03-05 17:56:35 +01:00 committed by Willy Tarreau
parent 9576ab7640
commit 0643b0e7e6
3 changed files with 22 additions and 12 deletions

View File

@ -405,7 +405,7 @@ struct proxy {
struct list logformat; /* log_format linked list */
struct list logformat_sd; /* log_format linked list for the RFC5424 structured-data part */
struct buffer log_tag; /* override default syslog tag */
char *header_unique_id; /* unique-id header */
struct ist header_unique_id; /* unique-id header */
struct list format_unique_id; /* unique-id format */
int to_log; /* things to be logged (LW_*) */
int stop_time; /* date to stop listening, when stopping != 0 (int ticks) */

View File

@ -429,8 +429,15 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
}
/* copy default header unique id */
if (defproxy.header_unique_id)
curproxy->header_unique_id = strdup(defproxy.header_unique_id);
if (isttest(defproxy.header_unique_id)) {
const struct ist copy = istdup(defproxy.header_unique_id);
if (!isttest(copy)) {
ha_alert("parsing [%s:%d] : failed to allocate memory for unique-id-header\n", file, linenum);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
curproxy->header_unique_id = copy;
}
/* default compression options */
if (defproxy.comp != NULL) {
@ -3484,13 +3491,21 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
}
else if (strcmp(args[0], "unique-id-header") == 0) {
char *copy;
if (!*(args[1])) {
ha_alert("parsing [%s:%d] : %s expects an argument.\n", file, linenum, args[0]);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
free(curproxy->header_unique_id);
curproxy->header_unique_id = strdup(args[1]);
copy = strdup(args[1]);
if (copy == NULL) {
ha_alert("parsing [%s:%d] : failed to allocate memory for unique-id-header\n", file, linenum);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
istfree(&curproxy->header_unique_id);
curproxy->header_unique_id = ist(copy);
}
else if (strcmp(args[0], "log-format") == 0) {

View File

@ -802,14 +802,9 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
}
/* send unique ID if a "unique-id-header" is defined */
if (sess->fe->header_unique_id) {
struct ist n, v;
n = ist2(sess->fe->header_unique_id, strlen(sess->fe->header_unique_id));
v = ist2(s->unique_id, length);
if (unlikely(!http_add_header(htx, n, v)))
if (isttest(sess->fe->header_unique_id) &&
!http_add_header(htx, sess->fe->header_unique_id, ist2(s->unique_id, length)))
goto return_int_err;
}
}
/*