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 995 : source::
18 : on_read(
19 : bool,
20 : boost::span<buffers::mutable_buffer const> bs) ->
21 : results
22 : {
23 995 : results rv;
24 995 : auto it = bs.begin();
25 995 : auto const end_ = bs.end();
26 995 : if(it == end_)
27 0 : return rv;
28 : do
29 : {
30 1968 : buffers::mutable_buffer b(*it++);
31 1968 : auto rs = on_read(b);
32 1968 : rv += rs;
33 1968 : if(rs.ec.failed())
34 4 : return rv;
35 1964 : if(rs.finished)
36 23 : break;
37 : // source must fill the entire buffer
38 : // if it is not finished
39 1941 : if(b.size() != rs.bytes)
40 0 : detail::throw_logic_error();
41 : }
42 1941 : while(it != end_);
43 991 : return rv;
44 : }
45 :
46 : } // http_proto
47 : } // boost
|