| 3290 | } |
| 3291 | |
| 3292 | inline bool read_content_with_length(Stream &strm, uint64_t len, |
| 3293 | Progress progress, |
| 3294 | ContentReceiverWithProgress out) { |
| 3295 | char buf[CPPHTTPLIB_RECV_BUFSIZ]; |
| 3296 | |
| 3297 | uint64_t r = 0; |
| 3298 | while (r < len) { |
| 3299 | auto read_len = static_cast<size_t>(len - r); |
| 3300 | auto n = strm.read(buf, (std::min)(read_len, CPPHTTPLIB_RECV_BUFSIZ)); |
| 3301 | if (n <= 0) { return false; } |
| 3302 | |
| 3303 | if (!out(buf, static_cast<size_t>(n), r, len)) { return false; } |
| 3304 | r += static_cast<uint64_t>(n); |
| 3305 | |
| 3306 | if (progress) { |
| 3307 | if (!progress(r, len)) { return false; } |
| 3308 | } |
| 3309 | } |
| 3310 | |
| 3311 | return true; |
| 3312 | } |
| 3313 | |
| 3314 | inline void skip_content_with_length(Stream &strm, uint64_t len) { |
| 3315 | char buf[CPPHTTPLIB_RECV_BUFSIZ]; |
no test coverage detected