| 3488 | } |
| 3489 | |
| 3490 | inline 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 | |
| 3512 | inline void skip_content_with_length(Stream &strm, uint64_t len) { |
| 3513 | char buf[CPPHTTPLIB_RECV_BUFSIZ]; |
no test coverage detected