return !(htx->flags & HTX_FL_EOM);
}
+/* Set EOM flag in <htx>. This function is useful if the HTX message is empty.
+ * In this case, an EOT block is appended first to ensure the EOM will be
+ * forwarded as expected. This is a workaround as it is not possibly currently
+ * to push an empty HTX DATA block.
+ *
+ * Returns 1 on success else 0.
+ */
+static inline int htx_set_eom(struct htx *htx)
+{
+ if (htx_is_empty(htx)) {
+ if (!htx_add_endof(htx, HTX_BLK_EOT))
+ return 0;
+ }
+
+ htx->flags |= HTX_FL_EOM;
+ return 1;
+}
+
/* Copy an HTX message stored in the buffer <msg> to <htx>. We take care to
* not overwrite existing data. All the message is copied or nothing. It returns
* 1 on success and 0 on error.
* EOM was already reported.
*/
if ((h2c->flags & H2_CF_IS_BACK) || !(h2s->flags & H2_SF_TUNNEL_ABRT)) {
- /* If we receive an empty DATA frame with ES flag while the HTX
- * message is empty, we must be sure to push a block to be sure
- * the HTX EOM flag will be handled on the other side. It is a
- * workaround because for now it is not possible to push empty
- * HTX DATA block. And without this block, there is no way to
- * "commit" the end of the message.
- */
- if (htx_is_empty(htx)) {
- if (!htx_add_endof(htx, HTX_BLK_EOT))
- goto fail;
- }
- htx->flags |= HTX_FL_EOM;
+ /* htx may be empty if receiving an empty DATA frame. */
+ if (!htx_set_eom(htx))
+ goto fail;
}
}