if (!(fstrm->flags & FCGI_SF_OUTGOING_DATA) && count)
fstrm->flags |= FCGI_SF_OUTGOING_DATA;
- while (fstrm->state < FCGI_SS_HLOC && !(fstrm->flags & FCGI_SF_BLK_ANY) &&
+ /* Nothing more can be sent once the empty STDIN record, marking the end
+ * of the request, was sent. Remaining data, if any, are drained below.
+ */
+ while (fstrm->state < FCGI_SS_HLOC && !(fstrm->flags & (FCGI_SF_BLK_ANY|FCGI_SF_ES_SENT)) &&
count && !htx_is_empty(htx)) {
blk = ASSUME_NONNULL(htx_get_head_blk(htx));
bsize = htx_get_blksz(blk);
}
done:
- if (fstrm->state >= FCGI_SS_HLOC) {
+ if (fstrm->state >= FCGI_SS_HLOC || (fstrm->flags & FCGI_SF_ES_SENT)) {
struct htx_ret htxret;
- /* trim any possibly pending data after we close (extra CR-LF,
- * unprocessed trailers, abnormal extra data, ...)
+ /* trim any possibly pending data after we close or after the
+ * end of the request (extra CR-LF, unprocessed trailers,
+ * abnormal extra data, a second EOM...)
*/
htxret = htx_drain(htx, count);
total += htxret.ret;