GCC Code Coverage Report


Directory: libs/http_proto/include/boost/http_proto/
File: boost/http_proto/impl/file_body.ipp
Date: 2023-03-02 17:13:10
Exec Total Coverage
Lines: 0 15 0.0%
Functions: 0 2 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 #ifndef BOOST_HTTP_PROTO_IMPL_FILE_BODY_IPP
11 #define BOOST_HTTP_PROTO_IMPL_FILE_BODY_IPP
12
13 #include <boost/http_proto/file_body.hpp>
14 #include <boost/buffers/algorithm.hpp>
15 #include <boost/assert.hpp>
16
17 namespace boost {
18 namespace http_proto {
19
20 file_body::
21 ~file_body() = default;
22
23 file_body::
24 file_body(
25 file_body&&) noexcept = default;
26
27 file_body::
28 file_body(
29 file&& f,
30 std::uint64_t size) noexcept
31 : f_(std::move(f))
32 , n_(size)
33 {
34 }
35
36 auto
37 file_body::
38 on_read(
39 buffers::mutable_buffer b) ->
40 results
41 {
42 results rv;
43 if(n_ > 0)
44 {
45 std::size_t n;
46 if( n_ >= b.size())
47 n = b.size();
48 else
49 n = n_;
50 n = f_.read(
51 b.data(), n, rv.ec);
52 rv.bytes = n;
53 n_ -= n;
54 }
55 rv.finished = n_ == 0;
56 return rv;
57 }
58
59 } // http_proto
60 } // boost
61
62 #endif
63