size_t qcs_http_rcv_buf(struct qcs *qcs, struct buffer *buf, size_t count,
char *fin);
-int qcs_http_handle_standalone_fin(struct qcs *qcs);
+int qcs_http_handle_standalone_fin(struct qcs *qcs, int force_eot);
size_t qcs_http_snd_buf(struct qcs *qcs, struct buffer *buf, size_t count,
char *fin);
goto out;
}
- prs_status = http_trailers_to_htx(list, 1, htx, (qcs->qcc->flags & QC_CF_IS_BACK) ? HTTP_PF_DIR_RES : 0);
+ prs_status = http_trailers_to_htx(list, fin, htx, (qcs->qcc->flags & QC_CF_IS_BACK) ? HTTP_PF_DIR_RES : 0);
switch (prs_status) {
case HTTP_PRS_SUCCESS:
break;
goto done;
}
- if (quic_stream_is_bidi(qcs->id) && qcs_http_handle_standalone_fin(qcs)) {
+ if (quic_stream_is_bidi(qcs->id) && qcs_http_handle_standalone_fin(qcs, h3s->st_req == H3S_ST_REQ_TRAILERS)) {
TRACE_ERROR("cannot set EOM", H3_EV_RX_FRAME, qcs->qcc->conn, qcs);
qcc_set_error(qcs->qcc, H3_ERR_INTERNAL_ERROR, 1,
muxc_tevt_type_internal_err);
}
/* Reuse wrapper function to easily set EOM on HTX message. */
- if (qcs_http_handle_standalone_fin(qcs)) {
+ if (qcs_http_handle_standalone_fin(qcs, h3s->st_req == H3S_ST_REQ_TRAILERS)) {
TRACE_ERROR("cannot set EOM", H3_EV_RX_FRAME, qcs->qcc->conn, qcs);
qcc_set_error(qcs->qcc, H3_ERR_INTERNAL_ERROR, 1,
muxc_tevt_type_internal_err);
BUG_ON(b_data(b) != b_contig_data(b, 0));
if (!b_data(b) && fin && quic_stream_is_bidi(qcs->id)) {
- if (qcs_http_handle_standalone_fin(qcs))
+ if (qcs_http_handle_standalone_fin(qcs, 0))
return -1;
return 0;
}
if (!to_copy) {
if (fin && quic_stream_is_bidi(qcs->id)) {
- if (qcs_http_handle_standalone_fin(qcs)) {
+ if (qcs_http_handle_standalone_fin(qcs, 0)) {
htx_to_buf(htx, htx_buf);
return -1;
}
return ret;
}
-/* Add EOM flag on input buffer for <qcs> instance.
+/* Add EOM flag on input buffer for <qcs> instance. If <force_eot> is set, EOT
+ * is manually inserted. This is necessary if HTX message contains not yet
+ * finalized trailers blocks.
+ *
* Returns 0 on success else non zero on internal error.
*/
-int qcs_http_handle_standalone_fin(struct qcs *qcs)
+int qcs_http_handle_standalone_fin(struct qcs *qcs, int force_eot)
{
struct buffer *appbuf;
struct htx *htx = NULL;
goto err;
htx = htx_from_buf(appbuf);
+ if (force_eot && !htx_add_endof(htx, HTX_BLK_EOT))
+ goto err;
+
if (!htx_set_eom(htx))
goto err;