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

Function read_content_with_length

examples/server/httplib.h:3490–3510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3488}
3489
3490inline bool read_content_with_length(Stream &strm, uint64_t len,
3491 Progress progress,
3492 ContentReceiverWithProgress out) {
3493 char buf[CPPHTTPLIB_RECV_BUFSIZ];
3494
3495 uint64_t r = 0;
3496 while (r < len) {
3497 auto read_len = static_cast<size_t>(len - r);
3498 auto n = strm.read(buf, (std::min)(read_len, CPPHTTPLIB_RECV_BUFSIZ));
3499 if (n <= 0) { return false; }
3500
3501 if (!out(buf, static_cast<size_t>(n), r, len)) { return false; }
3502 r += static_cast<uint64_t>(n);
3503
3504 if (progress) {
3505 if (!progress(r, len)) { return false; }
3506 }
3507 }
3508
3509 return true;
3510}
3511
3512inline void skip_content_with_length(Stream &strm, uint64_t len) {
3513 char buf[CPPHTTPLIB_RECV_BUFSIZ];

Callers 2

read_content_chunkedFunction · 0.85
read_contentFunction · 0.85

Calls 2

outFunction · 0.50
readMethod · 0.45

Tested by

no test coverage detected