h2s->flags &= ~H2_SF_MORE_HTX_DATA;
}
- if (!sd->iobuf.data)
+ if (sd->iobuf.data) {
+ total = sd->iobuf.data;
+ h2_set_frame_size(head, total);
+ if (es_now)
+ head[4] |= H2_F_DATA_END_STREAM;
+ b_add(mbuf, 9);
+ h2s->sws -= total;
+ h2c->mws -= total;
+ }
+ else if (!es_now || h2_send_empty_data_es(h2s) <= 0) {
+ /* Nothing was forwarded. On EOI, the end of the stream is
+ * reported using an empty DATA frame. The room reserved for
+ * the frame header by h2_nego_ff() is still there, so it
+ * should not fail. Otherwise, it will be emitted on shutdown.
+ */
goto end;
+ }
/* Perform a synchronous send but in all cases, consider
* everything was already sent from the SC point of view.
*/
- total = sd->iobuf.data;
- h2_set_frame_size(head, total);
- if (es_now)
- head[4] |= H2_F_DATA_END_STREAM;
- b_add(mbuf, 9);
- h2s->sws -= total;
- h2c->mws -= total;
if (h2_send(h2s->h2c))
tasklet_wakeup(h2s->h2c->wait_event.tasklet);