1 commit e22b3fb31968569194b1f848fadb4ca01f4dfc73
2 Author: Willy Tarreau <w@1wt.eu>
3 Date: Fri Jan 24 09:07:53 2020 +0100
5 BUG/MEDIUM: mux-h2: make sure we don't emit TE headers with anything but "trailers"
7 While the H2 parser properly checks for the absence of anything but
8 "trailers" in the TE header field, we forget to check this when sending
9 the request to an H2 server. The problem is that an H2->H2 conversion
10 may keep "gzip" and fail on the next stage.
12 This patch makes sure that we only send "TE: trailers" if the TE header
13 contains the "trailers" token, otherwise it's dropped.
15 This fixes issue #464 and should be backported till 1.9.
17 (cherry picked from commit bb2c4ae06566b8a8789caca4c48524aeb88cbc1b)
18 Signed-off-by: Willy Tarreau <w@1wt.eu>
20 diff --git a/src/mux_h2.c b/src/mux_h2.c
21 index 8a82f60fd..15a5cd757 100644
24 @@ -5034,23 +5034,36 @@ static size_t h2s_bck_make_req_headers(struct h2s *h2s, struct htx *htx)
25 * do not provide an authority.
27 for (hdr = 0; hdr < sizeof(list)/sizeof(list[0]); hdr++) {
28 + struct ist n = list[hdr].n;
29 + struct ist v = list[hdr].v;
31 /* these ones do not exist in H2 and must be dropped. */
32 - if (isteq(list[hdr].n, ist("connection")) ||
33 - (auth.len && isteq(list[hdr].n, ist("host"))) ||
34 - isteq(list[hdr].n, ist("proxy-connection")) ||
35 - isteq(list[hdr].n, ist("keep-alive")) ||
36 - isteq(list[hdr].n, ist("upgrade")) ||
37 - isteq(list[hdr].n, ist("transfer-encoding")))
38 + if (isteq(n, ist("connection")) ||
39 + (auth.len && isteq(n, ist("host"))) ||
40 + isteq(n, ist("proxy-connection")) ||
41 + isteq(n, ist("keep-alive")) ||
42 + isteq(n, ist("upgrade")) ||
43 + isteq(n, ist("transfer-encoding")))
46 + if (isteq(n, ist("te"))) {
47 + /* "te" may only be sent with "trailers" if this value
48 + * is present, otherwise it must be deleted.
50 + v = istist(v, ist("trailers"));
51 + if (!v.ptr || (v.len > 8 && v.ptr[8] != ','))
53 + v = ist("trailers");
56 /* Skip all pseudo-headers */
57 - if (*(list[hdr].n.ptr) == ':')
58 + if (*(n.ptr) == ':')
61 - if (isteq(list[hdr].n, ist("")))
62 + if (isteq(n, ist("")))
65 - if (!hpack_encode_header(&outbuf, list[hdr].n, list[hdr].v)) {
66 + if (!hpack_encode_header(&outbuf, n, v)) {
68 if (b_space_wraps(mbuf))