src/detail/drain_body.hpp

100.0% Lines (2/2) 100.0% List of functions (2/2) 100.0% Branches (1/1)
drain_body.hpp
f(x) Functions (2)
Line Branch TLA Hits Source Code
1 //
2 // Copyright (c) 2026 Mohammad Nejati
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/burl
8 //
9
10 #ifndef BOOST_BURL_SRC_DETAIL_DRAIN_BODY_HPP
11 #define BOOST_BURL_SRC_DETAIL_DRAIN_BODY_HPP
12
13 #include <boost/burl/message_reader.hpp>
14 #include <boost/burl/response_parser.hpp>
15
16 #include <boost/capy/buffers.hpp>
17 #include <boost/capy/concept/read_stream.hpp>
18 #include <boost/capy/cond.hpp>
19 #include <boost/capy/io_task.hpp>
20
21 #include <cstddef>
22
23 namespace boost
24 {
25 namespace burl
26 {
27 namespace detail
28 {
29
30 template<capy::ReadStream S>
31 capy::io_task<bool>
32
1/1
✓ Branch 1 taken 22 times.
22x drain_body(
33 S& stream,
34 response_parser& parser,
35 std::size_t attempts)
36 {
37 message_reader reader{ &stream, &parser };
38
39 while(!parser.got_body())
40 {
41 if(attempts-- == 0)
42 co_return { {}, false };
43
44 capy::const_buffer arr[8];
45 auto [ec, bufs] = co_await reader.pull(arr);
46 if(ec)
47 {
48 if(ec == capy::cond::eof)
49 break;
50 co_return { ec, false };
51 }
52 parser.consume(capy::buffer_size(bufs));
53 }
54 co_return { {}, true };
55 44x }
56
57 } // namespace detail
58 } // namespace burl
59 } // namespace boost
60
61 #endif
62