GCC Code Coverage Report


Directory: libs/http_proto/
File: libs/http_proto/src/file_body.cpp
Date: 2024-06-18 18:03:14
Exec Total Coverage
Lines: 0 18 0.0%
Functions: 0 4 0.0%
Branches: 0 4 0.0%

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