mirror of
https://github.com/matrix-construct/construct
synced 2025-02-18 09:40:12 +01:00
ircd::server: Add a complementary upload progress callback.
This commit is contained in:
parent
9da18261a6
commit
f1d659a6c0
2 changed files with 12 additions and 0 deletions
|
@ -42,6 +42,13 @@ struct ircd::server::out
|
||||||
{
|
{
|
||||||
const_buffer head;
|
const_buffer head;
|
||||||
const_buffer content;
|
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.
|
/// Request data and options related to the receive side of the request.
|
||||||
|
|
|
@ -1655,6 +1655,11 @@ ircd::server::tag::wrote_buffer(const const_buffer &buffer)
|
||||||
{
|
{
|
||||||
assert(data(buffer) == data(req.out.content));
|
assert(data(buffer) == data(req.out.content));
|
||||||
assert(written <= write_total());
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue