]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-h1: Don't emit C-L and T-E headers for 204 and 1xx responses
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 2 Dec 2020 15:17:15 +0000 (16:17 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 28 Jan 2021 15:37:14 +0000 (16:37 +0100)
204 and 1xx responses must not have any payload. Now, the H1 mux takes care
of that in last resort. But they also must not have any C-L or T-E
headers. Thus, if found on the sending path, these headers are ignored.

src/mux_h1.c

index 7b99f1a79c14de45e48496b95ed9aa3db1ef0882..266a2e70d75085f8b2eb7a62f3ff291b34016c0c 100644 (file)
@@ -1828,9 +1828,14 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun
                                if (*(n.ptr) == ':')
                                        goto skip_hdr;
 
-                               if (isteq(n, ist("transfer-encoding")))
+                               if (isteq(n, ist("transfer-encoding"))) {
+                                       if ((h1m->flags & H1_MF_RESP) && (h1s->status < 200 || h1s->status == 204))
+                                               goto skip_hdr;
                                        h1_parse_xfer_enc_header(h1m, v);
+                               }
                                else if (isteq(n, ist("content-length"))) {
+                                       if ((h1m->flags & H1_MF_RESP) && (h1s->status < 200 || h1s->status == 204))
+                                               goto skip_hdr;
                                        /* Only skip C-L header with invalid value. */
                                        if (h1_parse_cont_len_header(h1m, &v) < 0)
                                                goto skip_hdr;