src/detail/drain_body.cpp

100.0% Lines (2/2) 100.0% List of functions (1/1) 100.0% Branches (1/1)
drain_body.cpp
f(x) Functions (1)
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 #include "drain_body.hpp"
11
12 #include <boost/capy/error.hpp>
13
14 namespace boost
15 {
16 namespace burl
17 {
18 namespace detail
19 {
20
21 capy::io_task<bool>
22
1/1
✓ Branch 1 taken 22 times.
22x drain_body(
23 response_parser& parser,
24 std::size_t attempts)
25 {
26 while(!parser.got_body())
27 {
28 if(attempts-- == 0)
29 co_return { {}, false };
30
31 capy::const_buffer arr[8];
32 auto [ec, bufs] = co_await parser.pull(arr);
33 if(ec)
34 {
35 if(ec == capy::cond::eof)
36 break;
37 co_return { ec, false };
38 }
39 parser.consume(capy::buffer_size(bufs));
40 }
41 co_return { {}, true };
42 44x }
43
44 } // namespace detail
45 } // namespace burl
46 } // namespace boost
47