From: Willy Tarreau Date: Thu, 3 Jan 2019 16:39:54 +0000 (+0100) Subject: BUG/MEDIUM: mux-h1: make HTX chunking consistent with H2 X-Git-Tag: v2.0-dev1~293 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4710d20;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: mux-h1: make HTX chunking consistent with H2 When transfering from H1 to H1, chunking is always indicated by the presence of the Transfer-encoding header field. But when a message comes from H2 there is no such header and only HTX_SL_F_XFER_LEN ought to be relied on. This one will also result in H1_MF_XFER_LEN to be set, just like transfer-encoding, so let's always rely on this latter flag to detect the need for chunking (when CLEN is not here) and automatically add the transfer-encoding header if it was not present, as reported by H1_MF_CHNK. This must be backported to 1.9. --- diff --git a/src/mux_h1.c b/src/mux_h1.c index 7b82401168..7eff9d2f13 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -1533,6 +1533,14 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun goto copy; } } + + if ((h1m->flags & (H1_MF_CLEN|H1_MF_CHNK|H1_MF_XFER_LEN)) == H1_MF_XFER_LEN) { + /* chunking needed but header not seen */ + if (!chunk_memcat(tmp, "transfer-encoding: chunked\r\n", 28)) + goto copy; + h1m->flags |= H1_MF_CHNK; + } + h1m->state = H1_MSG_LAST_LF; if (!chunk_memcat(tmp, "\r\n", 2)) goto copy;