return ((h1m->state == H1_MSG_DONE) ? 0 : b_data(&h1s->h1c->ibuf));
}
+static inline void h1s_consume_kop(struct h1s *h1s, size_t count)
+{
+ if (h1s->sd->kop > count)
+ h1s->sd->kop -= count;
+ else
+ h1s->sd->kop = 0;
+}
+
/* Creates a new stream connector and the associate stream. <input> is used as input
* buffer for the stream. On success, it is transferred to the stream and the
* mux is no longer responsible of it. On error, <input> is unchanged, thus the
goto error;
}
h1m->curr_len = (h1s->sd->kop ? h1s->sd->kop : count);
- h1s->sd->kop = 0;
+ h1s_consume_kop(h1s, h1m->curr_len);
/* Because chunk meta-data are prepended, the chunk size of the current chunk
* must be handled before the end of the previous chunk.
h1m->curr_len = 0;
goto full;
}
- h1s->sd->kop = 0;
+ h1s_consume_kop(h1s, h1m->curr_len);
h1m->state = H1_MSG_DATA;
}
goto out;
}
h1m->curr_len = count;
+ h1s_consume_kop(h1s, h1m->curr_len);
}
else {
/* The producer does not know the chunk size, thus this will be emitted at the
struct buffer buf = b_make(b_orig(&h1c->obuf), b_size(&h1c->obuf),
b_peek_ofs(&h1c->obuf, b_data(&h1c->obuf) - sd->iobuf.data + sd->iobuf.offset),
sd->iobuf.data);
+
h1_prepend_chunk_size(&buf, sd->iobuf.data, sd->iobuf.offset - ((h1m->state == H1_MSG_CHUNK_CRLF) ? 2 : 0));
if (h1m->state == H1_MSG_CHUNK_CRLF)
h1_prepend_chunk_crlf(&buf);
b_add(&h1c->obuf, sd->iobuf.offset);
h1m->state = H1_MSG_CHUNK_CRLF;
+ h1s_consume_kop(h1s, sd->iobuf.data);
}
total = sd->iobuf.data;