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/buffers.hpp>
13 #include <boost/capy/error.hpp>
14
15 namespace boost
16 {
17 namespace burl
18 {
19 namespace detail
20 {
21
22 capy::io_task<>
23
1/1
✓ Branch 1 taken 10 times.
10x drain_body(
24 http::response_parser& parser,
25 capy::any_stream conn,
26 std::uint64_t limit)
27 {
28 auto source = parser.source_for(conn);
29 for(;;)
30 {
31 capy::const_buffer arr[2];
32 auto [ec, bufs] = co_await source.pull(arr);
33 if(ec == capy::cond::eof)
34 co_return {};
35 if(ec)
36 co_return { ec };
37
38 auto n = capy::buffer_size(bufs);
39 if(n > limit)
40 co_return {};
41 limit -= n;
42 source.consume(n);
43 }
44 20x }
45
46 } // namespace detail
47 } // namespace burl
48 } // namespace boost
49