MINOR: proxy: Store orgto_hdr_name as a struct ist
The orgto_hdr_name is already processed as an ist in `http_process_request`, lets also just store it as such. see 0643b0e7e ("MINOR: proxy: Make `header_unique_id` a `struct ist`") for a very similar past commit.
This commit is contained in:
parent
b50ab8489e
commit
e502c3e793
@ -353,8 +353,7 @@ struct proxy {
|
||||
struct net_addr except_xff_net; /* don't x-forward-for for this address. */
|
||||
struct net_addr except_xot_net; /* don't x-original-to for this address. */
|
||||
struct ist fwdfor_hdr_name; /* header to use - default: "x-forwarded-for" */
|
||||
char *orgto_hdr_name; /* header to use - default: "x-original-to" */
|
||||
int orgto_hdr_len; /* length of "x-original-to" header */
|
||||
struct ist orgto_hdr_name; /* header to use - default: "x-original-to" */
|
||||
char *server_id_hdr_name; /* the header to use to send the server id (name) */
|
||||
int server_id_hdr_len; /* the length of the id (name) header... name */
|
||||
int conn_retries; /* maximum number of connect retries */
|
||||
|
@ -2399,11 +2399,10 @@ stats_error_parsing:
|
||||
|
||||
curproxy->options |= PR_O_ORGTO;
|
||||
|
||||
free(curproxy->orgto_hdr_name);
|
||||
curproxy->orgto_hdr_name = strdup(DEF_XORIGINALTO_HDR);
|
||||
if (!curproxy->orgto_hdr_name)
|
||||
istfree(&curproxy->orgto_hdr_name);
|
||||
curproxy->orgto_hdr_name = istdup(ist(DEF_XORIGINALTO_HDR));
|
||||
if (!isttest(curproxy->orgto_hdr_name))
|
||||
goto alloc_error;
|
||||
curproxy->orgto_hdr_len = strlen(DEF_XORIGINALTO_HDR);
|
||||
curproxy->except_xot_net.family = AF_UNSPEC;
|
||||
|
||||
/* loop to go through arguments - start at 2, since 0+1 = "option" "originalto" */
|
||||
@ -2441,11 +2440,10 @@ stats_error_parsing:
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
free(curproxy->orgto_hdr_name);
|
||||
curproxy->orgto_hdr_name = strdup(args[cur_arg+1]);
|
||||
if (!curproxy->orgto_hdr_name)
|
||||
istfree(&curproxy->orgto_hdr_name);
|
||||
curproxy->orgto_hdr_name = istdup(ist(args[cur_arg+1]));
|
||||
if (!isttest(curproxy->orgto_hdr_name))
|
||||
goto alloc_error;
|
||||
curproxy->orgto_hdr_len = strlen(curproxy->orgto_hdr_name);
|
||||
cur_arg += 2;
|
||||
} else {
|
||||
/* unknown suboption - catchall */
|
||||
|
@ -711,8 +711,7 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
*/
|
||||
if ((sess->fe->options | s->be->options) & PR_O_ORGTO) {
|
||||
const struct sockaddr_storage *dst = si_dst(cs_si(s->csf));
|
||||
struct ist hdr = ist2(s->be->orgto_hdr_len ? s->be->orgto_hdr_name : sess->fe->orgto_hdr_name,
|
||||
s->be->orgto_hdr_len ? s->be->orgto_hdr_len : sess->fe->orgto_hdr_len);
|
||||
struct ist hdr = isttest(s->be->orgto_hdr_name) ? s->be->orgto_hdr_name : sess->fe->orgto_hdr_name;
|
||||
|
||||
if (dst && dst->ss_family == AF_INET) {
|
||||
/* Add an X-Original-To header unless the destination IP is
|
||||
|
@ -1440,7 +1440,7 @@ void proxy_free_defaults(struct proxy *defproxy)
|
||||
ha_free(&defproxy->defbe.name);
|
||||
ha_free(&defproxy->conn_src.iface_name);
|
||||
istfree(&defproxy->fwdfor_hdr_name);
|
||||
ha_free(&defproxy->orgto_hdr_name); defproxy->orgto_hdr_len = 0;
|
||||
istfree(&defproxy->orgto_hdr_name);
|
||||
ha_free(&defproxy->server_id_hdr_name); defproxy->server_id_hdr_len = 0;
|
||||
|
||||
list_for_each_entry_safe(acl, aclb, &defproxy->acl, list) {
|
||||
@ -1604,10 +1604,8 @@ static int proxy_defproxy_cpy(struct proxy *curproxy, const struct proxy *defpro
|
||||
if (isttest(defproxy->fwdfor_hdr_name))
|
||||
curproxy->fwdfor_hdr_name = istdup(defproxy->fwdfor_hdr_name);
|
||||
|
||||
if (defproxy->orgto_hdr_len) {
|
||||
curproxy->orgto_hdr_len = defproxy->orgto_hdr_len;
|
||||
curproxy->orgto_hdr_name = strdup(defproxy->orgto_hdr_name);
|
||||
}
|
||||
if (isttest(defproxy->orgto_hdr_name))
|
||||
curproxy->orgto_hdr_name = istdup(defproxy->orgto_hdr_name);
|
||||
|
||||
if (defproxy->server_id_hdr_len) {
|
||||
curproxy->server_id_hdr_len = defproxy->server_id_hdr_len;
|
||||
|
Loading…
x
Reference in New Issue
Block a user