| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2022 Vinnie Falco (vinnie.falco@gmail.com) | ||
| 3 | // Copyright (c) 2025 Mohammad Nejati | ||
| 4 | // | ||
| 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
| 7 | // | ||
| 8 | // Official repository: https://github.com/cppalliance/http_proto | ||
| 9 | // | ||
| 10 | |||
| 11 | #include <boost/http_proto/file_source.hpp> | ||
| 12 | |||
| 13 | namespace boost { | ||
| 14 | namespace http_proto { | ||
| 15 | |||
| 16 | 3 | file_source:: | |
| 17 | ~file_source() = default; | ||
| 18 | |||
| 19 | ✗ | file_source:: | |
| 20 | file_source(file_source&&) noexcept = default; | ||
| 21 | |||
| 22 | 3 | file_source:: | |
| 23 | file_source( | ||
| 24 | file&& f, | ||
| 25 | 3 | std::uint64_t limit) noexcept | |
| 26 | 3 | : f_(std::move(f)) | |
| 27 | 3 | , n_(limit) | |
| 28 | { | ||
| 29 | 3 | } | |
| 30 | |||
| 31 | auto | ||
| 32 | 7 | file_source:: | |
| 33 | on_read( | ||
| 34 | buffers::mutable_buffer b) -> results | ||
| 35 | { | ||
| 36 | 7 | results rv; | |
| 37 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if(n_ > 0) |
| 38 | { | ||
| 39 | std::size_t n; | ||
| 40 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1 times.
|
7 | if( n_ >= b.size()) |
| 41 | 6 | n = b.size(); | |
| 42 | else | ||
| 43 | 1 | n = static_cast<std::size_t>(n_); | |
| 44 | 7 | n = f_.read( | |
| 45 | b.data(), n, rv.ec); | ||
| 46 | 7 | rv.bytes = n; | |
| 47 |
7/8✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 6 times.
|
7 | if(n == 0 && b.size() != 0 && !rv.ec) |
| 48 | { | ||
| 49 | 1 | rv.finished = true; | |
| 50 | 1 | return rv; | |
| 51 | } | ||
| 52 | 6 | n_ -= n; | |
| 53 | } | ||
| 54 | 6 | rv.finished = n_ == 0; | |
| 55 | 6 | return rv; | |
| 56 | } | ||
| 57 | |||
| 58 | } // http_proto | ||
| 59 | } // boost | ||
| 60 |