mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 16:47:18 +02:00
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:
parent
9576ab7640
commit
0643b0e7e6
@ -405,7 +405,7 @@ struct proxy {
|
|||||||
struct list logformat; /* log_format linked list */
|
struct list logformat; /* log_format linked list */
|
||||||
struct list logformat_sd; /* log_format linked list for the RFC5424 structured-data part */
|
struct list logformat_sd; /* log_format linked list for the RFC5424 structured-data part */
|
||||||
struct buffer log_tag; /* override default syslog tag */
|
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 */
|
struct list format_unique_id; /* unique-id format */
|
||||||
int to_log; /* things to be logged (LW_*) */
|
int to_log; /* things to be logged (LW_*) */
|
||||||
int stop_time; /* date to stop listening, when stopping != 0 (int ticks) */
|
int stop_time; /* date to stop listening, when stopping != 0 (int ticks) */
|
||||||
|
@ -429,8 +429,15 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* copy default header unique id */
|
/* copy default header unique id */
|
||||||
if (defproxy.header_unique_id)
|
if (isttest(defproxy.header_unique_id)) {
|
||||||
curproxy->header_unique_id = strdup(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 */
|
/* default compression options */
|
||||||
if (defproxy.comp != NULL) {
|
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) {
|
else if (strcmp(args[0], "unique-id-header") == 0) {
|
||||||
|
char *copy;
|
||||||
if (!*(args[1])) {
|
if (!*(args[1])) {
|
||||||
ha_alert("parsing [%s:%d] : %s expects an argument.\n", file, linenum, args[0]);
|
ha_alert("parsing [%s:%d] : %s expects an argument.\n", file, linenum, args[0]);
|
||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
free(curproxy->header_unique_id);
|
copy = strdup(args[1]);
|
||||||
curproxy->header_unique_id = 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) {
|
else if (strcmp(args[0], "log-format") == 0) {
|
||||||
|
@ -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 */
|
/* send unique ID if a "unique-id-header" is defined */
|
||||||
if (sess->fe->header_unique_id) {
|
if (isttest(sess->fe->header_unique_id) &&
|
||||||
struct ist n, v;
|
!http_add_header(htx, sess->fe->header_unique_id, ist2(s->unique_id, length)))
|
||||||
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)))
|
|
||||||
goto return_int_err;
|
goto return_int_err;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user