MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / write_content

Function write_content

examples/server/httplib.h:3705–3738  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3703
3704template <typename T>
3705inline bool write_content(Stream &strm, const ContentProvider &content_provider,
3706 size_t offset, size_t length, T is_shutting_down,
3707 Error &error) {
3708 size_t end_offset = offset + length;
3709 auto ok = true;
3710 DataSink data_sink;
3711
3712 data_sink.write = [&](const char *d, size_t l) -> bool {
3713 if (ok) {
3714 if (strm.is_writable() && write_data(strm, d, l)) {
3715 offset += l;
3716 } else {
3717 ok = false;
3718 }
3719 }
3720 return ok;
3721 };
3722
3723 while (offset < end_offset && !is_shutting_down()) {
3724 if (!strm.is_writable()) {
3725 error = Error::Write;
3726 return false;
3727 } else if (!content_provider(offset, end_offset - offset, data_sink)) {
3728 error = Error::Canceled;
3729 return false;
3730 } else if (!ok) {
3731 error = Error::Write;
3732 return false;
3733 }
3734 }
3735
3736 error = Error::Success;
3737 return true;
3738}
3739
3740template <typename T>
3741inline bool write_content(Stream &strm, const ContentProvider &content_provider,

Callers 2

Calls 2

write_dataFunction · 0.85
is_writableMethod · 0.80

Tested by

no test coverage detected