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

Function write_content_without_length

examples/server/httplib.h:3750–3779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3748
3749template <typename T>
3750inline bool
3751write_content_without_length(Stream &strm,
3752 const ContentProvider &content_provider,
3753 const T &is_shutting_down) {
3754 size_t offset = 0;
3755 auto data_available = true;
3756 auto ok = true;
3757 DataSink data_sink;
3758
3759 data_sink.write = [&](const char *d, size_t l) -> bool {
3760 if (ok) {
3761 offset += l;
3762 if (!strm.is_writable() || !write_data(strm, d, l)) { ok = false; }
3763 }
3764 return ok;
3765 };
3766
3767 data_sink.done = [&](void) { data_available = false; };
3768
3769 while (data_available && !is_shutting_down()) {
3770 if (!strm.is_writable()) {
3771 return false;
3772 } else if (!content_provider(offset, 0, data_sink)) {
3773 return false;
3774 } else if (!ok) {
3775 return false;
3776 }
3777 }
3778 return true;
3779}
3780
3781template <typename T, typename U>
3782inline bool

Callers 1

Calls 2

write_dataFunction · 0.85
is_writableMethod · 0.80

Tested by

no test coverage detected