From: Christopher Faulet Date: Wed, 14 Aug 2019 14:32:25 +0000 (+0200) Subject: MINOR: muxes/htx: Ignore pseudo header during message formatting X-Git-Tag: v2.1-dev2~67 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=86d144c74be52d0f0b3dd99713c0fee2383a9a9b;p=thirdparty%2Fhaproxy.git MINOR: muxes/htx: Ignore pseudo header during message formatting 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. --- diff --git a/src/mux_h1.c b/src/mux_h1.c index 7cc7ba6eba..ee12686bbc 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -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"))) { diff --git a/src/mux_h2.c b/src/mux_h2.c index 33ba9bbfe1..fababa1903 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -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))