]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mux-h1: Always set CS_FL_EOI for response in MSG_DONE state
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 8 Feb 2021 16:18:01 +0000 (17:18 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 10 Feb 2021 15:25:42 +0000 (16:25 +0100)
During the message parsing, if in MSG_DONE state, the CS_FL_EOI flag must
always be set on the conn-stream if following conditions are met :

  * It is a response or
  * It is a request but not a protocol upgrade nor a CONNECT.

For now, there is no test on the message type (request or response). Thus
the CS_FL_EOI flag is not set for a response with a "Connection: upgrade"
header but not a 101 response.

This bug was introduced by the commit 3e1748bbf ("BUG/MINOR: mux-h1: Don't
set CS_FL_EOI too early for protocol upgrade requests"). It was backported
as far as 2.0. Thus, this patch must also be backported as far as 2.0.

src/mux_h1.c

index 8f96cdf91c7944b7189df86fdfd23ae8d1159cd1..b5772519bd37083ec64764b6d62579fd5d1c1b81 100644 (file)
@@ -1681,11 +1681,15 @@ static size_t h1_process_input(struct h1c *h1c, struct buffer *buf, size_t count
                h1s->cs->flags &= ~CS_FL_MAY_SPLICE;
        }
 
-       /* Don't set EOI on the conn-stream for protocol upgrade or connect
-        * requests, wait the response to do so or not depending on the status
+       /* Set EOI on conn-stream in DONE state iff:
+        *  - it is a response
+        *  - it is a request but no a protocol upgrade nor a CONNECT
+        *
+        * If not set, Wait the response to do so or not depending on the status
         * code.
         */
-       if ((h1m->state == H1_MSG_DONE) && (h1s->meth != HTTP_METH_CONNECT) && !(h1m->flags & H1_MF_CONN_UPG))
+       if (((h1m->state == H1_MSG_DONE) && (h1m->flags & H1_MF_RESP)) ||
+           ((h1m->state == H1_MSG_DONE) && (h1s->meth != HTTP_METH_CONNECT) && !(h1m->flags & H1_MF_CONN_UPG)))
                h1s->cs->flags |= CS_FL_EOI;
 
        if (h1s_data_pending(h1s) && !htx_is_empty(htx))