]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http: Remove headers matching the name of http-send-name-header option
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 2 Oct 2019 08:51:38 +0000 (10:51 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 4 Oct 2019 14:12:02 +0000 (16:12 +0200)
It is not explicitly stated in the documentation, but some users rely on this
behavior. When the server name is inserted in a request, headers with the same
name are first removed.

This patch is not tagged as a bug, because it is not explicitly documented. We
choose to keep the same implicit behavior to not break existing
configuration. Because this option is used very little, it is not a big deal.

src/mux_fcgi.c
src/mux_h1.c
src/mux_h2.c

index d66c8af1e8796b38434bb28adc52283a4b5171cb..c459e76a9a4cedb6bcf45fb763c5fce942deb7e3 100644 (file)
@@ -1588,6 +1588,11 @@ static size_t fcgi_strm_send_params(struct fcgi_conn *fconn, struct fcgi_strm *f
                                        if (isteq(p.n, ist("host")))
                                                params.srv_name = p.v;
 
+                                       /* Skip header if same name is used to add the server name */
+                                       if (fconn->proxy->server_id_hdr_name &&
+                                           isteq(p.n, ist2(fconn->proxy->server_id_hdr_name, fconn->proxy->server_id_hdr_len)))
+                                               break;
+
                                        memcpy(trash.area, "http_", 5);
                                        memcpy(trash.area+5, p.n.ptr, p.n.len);
                                        p.n = ist2(trash.area, p.n.len+5);
index 2906953ffcab78e1cc6b0de5c93ae3b72834631b..d928c57f64ba36ea01797b40f9fb159ccdbd9759 100644 (file)
@@ -1641,6 +1641,11 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun
                                                goto skip_hdr;
                                }
 
+                               /* Skip header if same name is used to add the server name */
+                               if (!(h1m->flags & H1_MF_RESP) && h1c->px->server_id_hdr_name &&
+                                   isteqi(n, ist2(h1c->px->server_id_hdr_name, h1c->px->server_id_hdr_len)))
+                                       goto skip_hdr;
+
                                /* Try to adjust the case of the header name */
                                if (h1c->px->options2 & (PR_O2_H1_ADJ_BUGCLI|PR_O2_H1_ADJ_BUGSRV))
                                        h1_adjust_case_outgoing_hdr(h1s, h1m, &n);
index 34c580d694dc4436f9b57b0eda749843b348b365..fc4b02f6366b44629adfc9d296e69bf5d7f7dd2f 100644 (file)
@@ -4776,6 +4776,12 @@ static size_t h2s_bck_make_req_headers(struct h2s *h2s, struct htx *htx)
 
                list[hdr].n = htx_get_blk_name(htx, blk);
                list[hdr].v = htx_get_blk_value(htx, blk);
+
+               /* Skip header if same name is used to add the server name */
+               if ((h2c->flags & H2_CF_IS_BACK) && h2c->proxy->server_id_hdr_name &&
+                   isteq(list[hdr].n, ist2(h2c->proxy->server_id_hdr_name, h2c->proxy->server_id_hdr_len)))
+                       continue;
+
                hdr++;
        }