]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: mux-h1: accept a late EOM on content-length messages
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 2 Dec 2026 13:47:18 +0000 (14:47 +0100)
committerOlivier Houchard <cognet@ci0.org>
Wed, 2 Dec 2026 13:33:36 +0000 (14:33 +0100)
When the last bytes of a message with a content-length are sent by the
zero-copy path of h1_make_data() or by h1_done_ff() before the EOM is
known, the message is switched to H1_MSG_TRAILERS. If the EOM then comes
alone on a NOOP block, h1_make_trailers() reports a processing error.
This happens when an H2 peer sends END_STREAM in a separate empty DATA
frame after the payload was already forwarded, e.g. a node client piping
a stream into a request with a content-length: the client gets a 500
with "IH--" although the server received the whole request. With an H2
server doing the same, the response is logged with "ID--" and the client
connection is not kept alive.

Let's end the message when a NOOP block carrying the EOM is found in
h1_make_trailers() and the message is not chunked. It remains an error
for chunked messages, for which the EOM is expected on the EOT block.
This was brought in 3.5-dev14 by commit e99253b70 ("BUG/MINOR: mux-h1:
properly handle NOOP blocks and track EOM emission"), so no backport is
needed.

src/mux_h1.c

index 582872e374e87b94f1882291e9834bc237aa62ea..c8ee5b011228d28766d343128aba4e06c8f6663d 100644 (file)
@@ -3632,9 +3632,13 @@ static size_t h1_make_trailers(struct h1s *h1s, struct h1m *h1m, struct htx *htx
                                h1s->flags |= H1S_F_EOM_SENT;
                }
                else if (type == HTX_BLK_NOOP) {
-                       /* Consume the NOOP block, nothing is emitted. But EOM is unexpected before EOT */
-                       if (blk->flags & HTX_BLK_FL_EOM)
-                               goto error;
+                       /* Consume the NOOP block, nothing is emitted. EOM is unexpected for chunked messages */
+                       if (blk->flags & HTX_BLK_FL_EOM) {
+                               if (h1m->flags & H1_MF_CHNK)
+                                       goto error;
+                               h1m->state = H1_MSG_DONE;
+                               h1s->flags |= H1S_F_EOM_SENT;
+                       }
                }
 
          nextblk: