]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: muxes/htx: Ignore pseudo header during message formatting
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 14 Aug 2019 14:32:25 +0000 (16:32 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 17 Sep 2019 08:18:54 +0000 (10:18 +0200)
When an HTX message is formatted to an H1 or H2 message, pseudo-headers (with
header names starting by a colon (':')) are now ignored. In fact, for now, only
H2 messages have such headers, and the H2 mux already skips them when it creates
the HTX message. But in the futur, it may be useful to keep these headers in the
HTX message to help the message analysis or to do some processing during the
HTTP formatting. It would also be a good idea to have scopes for pseudo-headers
(:h1-, :h2-, :fcgi-...) to limit their usage to a specific mux.

src/mux_h1.c
src/mux_h2.c

index 7cc7ba6eba76e97bce6c72a5304c17613c718984..ee12686bbc25d1443eb4b453272d25a5b3a45e64 100644 (file)
@@ -1270,6 +1270,10 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun
                                n = htx_get_blk_name(chn_htx, blk);
                                v = htx_get_blk_value(chn_htx, blk);
 
+                               /* Skip all pseudo-headers */
+                               if (*(n.ptr) == ':')
+                                       goto skip_hdr;
+
                                if (isteqi(n, ist("transfer-encoding")))
                                        h1_parse_xfer_enc_header(h1m, v);
                                else if (isteqi(n, ist("content-length"))) {
index 33ba9bbfe11579b026b6b3e5850507157b97bcbe..fababa19030557de775aff66284a28db77c6c18a 100644 (file)
@@ -4525,6 +4525,10 @@ static size_t h2s_frt_make_resp_headers(struct h2s *h2s, struct htx *htx)
                    isteq(list[hdr].n, ist("transfer-encoding")))
                        continue;
 
+               /* Skip all pseudo-headers */
+               if (*(list[hdr].n.ptr) == ':')
+                       continue;
+
                if (isteq(list[hdr].n, ist("")))
                        break; // end
 
@@ -4793,6 +4797,10 @@ static size_t h2s_bck_make_req_headers(struct h2s *h2s, struct htx *htx)
                    isteq(list[hdr].n, ist("transfer-encoding")))
                        continue;
 
+               /* Skip all pseudo-headers */
+               if (*(list[hdr].n.ptr) == ':')
+                       continue;
+
                if (isteq(list[hdr].n, ist("")))
                        break; // end
 
@@ -5263,6 +5271,10 @@ static size_t h2s_make_trailers(struct h2s *h2s, struct htx *htx)
                    isteq(list[idx].n, ist("transfer-encoding")))
                        continue;
 
+               /* Skip all pseudo-headers */
+               if (*(list[idx].n.ptr) == ':')
+                       continue;
+
                if (!hpack_encode_header(&outbuf, list[idx].n, list[idx].v)) {
                        /* output full */
                        if (b_space_wraps(mbuf))