* subsequently to a successful send. Returns the number of data bytes
* consumed, or zero if nothing done. Note that EOD/EOM count for 1 byte.
*/
-static size_t h2s_htx_frt_make_resp_data(struct h2s *h2s, struct htx *htx)
+static size_t h2s_htx_frt_make_resp_data(struct h2s *h2s, struct htx *htx, size_t count)
{
struct h2c *h2c = h2s->h2c;
struct buffer outbuf;
*/
new_frame:
- if (htx_is_empty(htx))
+ if (!count || htx_is_empty(htx))
goto end;
idx = htx_get_head(htx);
* deal with. Let's simply remove the EOD and return.
*/
htx_remove_blk(htx, blk);
- // FIXME, it seems we must not return it in the total bytes count?
- //total++; // EOD counts as one byte
+ total++; // EOD counts as one byte
+ count--;
goto end;
}
goto end;
}
+ if (fsize > count)
+ fsize = count;
+
if (fsize > h2s->mws)
fsize = h2s->mws; // >0
memcpy(outbuf.area + 9, htx_get_blk_ptr(htx, blk), fsize);
h2s->mws -= fsize;
h2c->mws -= fsize;
+ count -= fsize;
send_empty:
/* update the frame's size */
* meeting EOM. We should optimize this later.
*/
if (type == HTX_BLK_EOM) {
- // FIXME, it seems we must not return it in the total bytes count?
- // total++; // EOM counts as one byte
+ total++; // EOM counts as one byte
+ count--;
es_now = 1;
}
case HTX_BLK_EOD:
case HTX_BLK_EOM:
/* all these cause the emission of a DATA frame (possibly empty) */
- ret = h2s_htx_frt_make_resp_data(h2s, htx);
+ ret = h2s_htx_frt_make_resp_data(h2s, htx, count);
if (ret > 0) {
total += ret;
count -= ret;