]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http-htx: Properly set htx flags on error files to support keep-alive
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 16 Oct 2019 07:09:04 +0000 (09:09 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 16 Oct 2019 08:03:12 +0000 (10:03 +0200)
When an error file was loaded, the flag HTX_SL_F_XFER_LEN was never set on the
HTX start line because of a bug. During the headers parsing, the flag
H1_MF_XFER_LEN is never set on the h1m. But it was the condition to set
HTX_SL_F_XFER_LEN on the HTX start-line. Instead, we must only rely on the flags
H1_MF_CLEN or H1_MF_CHNK.

Because of this bug, it was impossible to keep a connection alive for a response
generated by HAProxy. Now the flag HTX_SL_F_XFER_LEN is set when an error file
have a content length (chunked responses are unsupported at this stage) and the
connection may be kept alive if there is no connection header specified to
explicitly close it.

This patch must be backported to 2.0 and 1.9.

src/http_htx.c

index dbe9f67c746419be986eb67edb81ade35c97aca2..7489f628847aa845ae1034ec51d3650d84ff0f8b 100644 (file)
@@ -771,16 +771,13 @@ int http_str_to_htx(struct buffer *buf, struct ist raw)
                flags |= HTX_SL_F_VER_11;
        if (h1m.flags & H1_MF_XFER_ENC)
                flags |= HTX_SL_F_XFER_ENC;
-       if (h1m.flags & H1_MF_XFER_LEN) {
-               flags |= HTX_SL_F_XFER_LEN;
-               if (h1m.flags & H1_MF_CHNK)
-                       goto error; /* Unsupported because there is no body parsing */
-               else if (h1m.flags & H1_MF_CLEN) {
-                       flags |= HTX_SL_F_CLEN;
-                       if (h1m.body_len == 0)
-                               flags |= HTX_SL_F_BODYLESS;
-               }
+       if (h1m.flags & H1_MF_CLEN) {
+               flags |= (HTX_SL_F_XFER_LEN|HTX_SL_F_CLEN);
+               if (h1m.body_len == 0)
+                       flags |= HTX_SL_F_BODYLESS;
        }
+       if (h1m.flags & H1_MF_CHNK)
+               goto error; /* Unsupported because there is no body parsing */
 
        htx = htx_from_buf(buf);
        sl = htx_add_stline(htx, HTX_BLK_RES_SL, flags, h1sl.st.v, h1sl.st.c, h1sl.st.r);