0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 00:32:35 +01:00

ircd::server: Add a complementary upload progress callback.

This commit is contained in:
Jason Volk 2018-01-21 05:01:25 -08:00
parent 9da18261a6
commit f1d659a6c0
2 changed files with 12 additions and 0 deletions

View file

@ -42,6 +42,13 @@ struct ircd::server::out
{
const_buffer head;
const_buffer content;
/// The progress closure is an optional callback invoked every time more
/// content is written to the socket. The first argument is a view of the
/// data most recently written. The second argument is a view of all data
/// written so far. This is only invoked for content. At the first
/// invocation, the head has been fully written.
std::function<void (const_buffer, const_buffer) noexcept> progress;
};
/// Request data and options related to the receive side of the request.

View file

@ -1655,6 +1655,11 @@ ircd::server::tag::wrote_buffer(const const_buffer &buffer)
{
assert(data(buffer) == data(req.out.content));
assert(written <= write_total());
// Invoke the user's optional progress callback; this function
// should be marked noexcept and has no reason to throw yet.
if(req.out.progress)
req.out.progress(buffer, const_buffer{data(req.out.content), written});
}
else
{