When the first record of a request is sent, the length of the body must be
known, either because a content-length was announced or because the whole
message was received. In this last case, the tail block of the HTX message
must carry the EOM flag. But since the commit
221c40bbf ("MINOR: htx: Add
a noop block to carry the EOM flag on an empty message"), an EOT block
without the EOM flag is a valid state, the EOM flag being reported later
on a NOOP block. It happens for instance when an H3 request is received
with trailers, the FIN being received in a separate frame. The wait for
the request body stops on the trailers, the payload being fully received.
So such request was rejected by the FCGI mux with a parsing error.
Now, the request is also accepted when the tail block is an EOT block.
The CONTENT_LENGTH parameter is already computed by counting the DATA
blocks up to the trailers. The empty STDIN record will be sent on the NOOP
block carrying the EOM flag.
This patch must be backported to 3.5.
/* Check if length of the body is known or if the message is
- * full. Otherwise, the request is invalid.
+ * full. Otherwise, the request is invalid. The message is full
+ * if the end of the message was reached or if the trailers were
+ * received. In this last case, the EOM flag may be received
+ * later, on a NOOP block.
*/
sl = http_get_stline(htx);
blk = htx_get_tail_blk(htx);
- if (!sl || (!(sl->flags & HTX_SL_F_CLEN) && !(blk->flags & HTX_BLK_FL_EOM))) {
+ if (!sl || (!(sl->flags & HTX_SL_F_CLEN) &&
+ !(blk->flags & HTX_BLK_FL_EOM) && htx_get_blk_type(blk) != HTX_BLK_EOT)) {
htx->flags |= HTX_FL_PARSING_ERROR;
fcgi_strm_error(fstrm);
goto done;