BUG/MEDIUM: mux-fcgi: Properly handle EOM flag on end-of-trailers HTX block

Trailers are skipped by the FCGI multiplexer. However empty chunked messages
are not properly handled. It may be a chunked H1 request with no payload or
a H2/H3 POST request with no payload. In that caes, the EOT HTX block is
just ignored. The issue is that the EOM flag is thus ignored too. It means
no empty STDIN record is sent to mark the end of the request to the server.

To fix the issue, when a EOT htx block is found and it is the last HTX block
of the message (and it should be), the EOM flag is tested. If it is found,
an empty STDIN record is emitted.

This patch should fix the issue #2499. It must be backported as far as 2.4.
This commit is contained in:
Christopher Faulet 2024-03-25 08:02:06 +01:00
parent bd384a359b
commit 56c4b29ff1

View File

@ -4043,6 +4043,15 @@ static size_t fcgi_snd_buf(struct stconn *sc, struct buffer *buf, size_t count,
}
break;
case HTX_BLK_EOT:
if (htx_is_unique_blk(htx, blk) && (htx->flags & HTX_FL_EOM)) {
TRACE_PROTO("sending FCGI STDIN record", FCGI_EV_TX_RECORD|FCGI_EV_TX_STDIN, fconn->conn, fstrm, htx);
ret = fcgi_strm_send_empty_stdin(fconn, fstrm);
if (!ret)
goto done;
}
__fallthrough;
default:
remove_blk:
htx_remove_blk(htx, blk);