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.
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: