Line data Source code
1 : //
2 : // Copyright (c) 2023 Vinnie Falco (vinnie.falco@gmail.com)
3 : // Copyright (c) 2025 Mohammad Nejati
4 : //
5 : // Distributed under the Boost Software License, Version 1.0. (See accompanying
6 : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 : //
8 : // Official repository: https://github.com/cppalliance/http_proto
9 : //
10 :
11 : #include <boost/http_proto/source.hpp>
12 :
13 : namespace boost {
14 : namespace http_proto {
15 :
16 : auto
17 2719 : source::
18 : on_read(
19 : buffers::mutable_buffer_span bs) ->
20 : results
21 : {
22 2719 : results rv;
23 2719 : auto it = bs.begin();
24 2719 : auto const end_ = bs.end();
25 2719 : if(it == end_)
26 1 : return rv;
27 : do
28 : {
29 5406 : buffers::mutable_buffer b(*it++);
30 5406 : auto rs = on_read(b);
31 5406 : rv += rs;
32 5406 : if(rs.ec.failed())
33 4 : return rv;
34 5402 : if(rs.finished)
35 31 : break;
36 : // Source must fill the entire buffer
37 : // unless it has finished
38 5371 : if(b.size() != rs.bytes)
39 0 : detail::throw_logic_error();
40 : }
41 5371 : while(it != end_);
42 2714 : return rv;
43 : }
44 :
45 : } // http_proto
46 : } // boost
|