]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: h1: ensure that 1xx, 204 and 304 don't have a payload body
authorWilly Tarreau <w@1wt.eu>
Mon, 30 Oct 2017 18:31:59 +0000 (19:31 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 30 Oct 2017 18:33:22 +0000 (19:33 +0100)
It's important for the H2 to H1 gateway that the response parser properly
clears the H1 message's body_len when seeing these status codes so that we
don't hang waiting to transfer data that will not come.

src/h1.c

index 7e8f19d51ac4a792cd3a436428428c6b4b9eb379..856b654ddfae70259bea79c5c42d3422a48bc994 100644 (file)
--- a/src/h1.c
+++ b/src/h1.c
@@ -1127,7 +1127,14 @@ int h1_headers_to_hdr_list(char *start, const char *stop,
                if (h1m) {
                        long long cl;
 
-                       if (isteq(n, ist("transfer-encoding"))) {
+                       if (start[st_c] == '1' || /* 100..199 */
+                           isteq(ist2(start + st_c, st_c_l), ist("204")) ||
+                           isteq(ist2(start + st_c, st_c_l), ist("304"))) {
+                               /* no contents, claim c-len is present and set to zero */
+                               h1m->flags |= H1_MF_CLEN;
+                               h1m->curr_len = h1m->body_len = 0;
+                       }
+                       else if (isteq(n, ist("transfer-encoding"))) {
                                h1m->flags &= ~H1_MF_CLEN;
                                h1m->flags |= H1_MF_CHNK;
                        }